QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#588641 | #7638. Lake | LuCiiiD | WA | 0ms | 3716kb | C++23 | 1.6kb | 2024-09-25 13:49:21 | 2024-09-25 13:49:22 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
//--------------------------------
// #define int long long
#define LL long long
// #define lc p << 1
// #define rc p << 1 | 1
#define lowbit(x) x & (-x)
#define nc() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2) ? EOF : *p1++)
// #pragma GCC optimize(2)
#define Blizzard ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
inline void read(LL &a)
{
LL s = 0, w = 1;
char ch = getchar();
while (ch < '0' || ch > '9')
{
if (ch == '-')
w = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9')
{
s = s * 10 + ch - '0';
ch = getchar();
}
a = s * w;
}
//-----------------------------------------
void solve()
{
int n, m;
cin >> n >> m;
if (n == 0 && m == 0)
{
cout << 0;
return;
}
int k1 = 0, k2 = 0;
k1 = n / 4;
k1 += ((n % 4 == 0) ? 0 : 1);
int t = n % 4;
if (t)
m = m - k1 * 3 - t - (4 - t);
else
m = m - k1 * 3;
if (m <= 0)
{
cout << 2 * k1 - 1;
return;
}
else
{
// cout << m << endl;
k2 = m / 4;
if (m % 4)
k2++;
// cout << k1 << " " << k2 << endl;
cout << (k2 + k1) * 2 - 1;
}
}
signed main()
{
Blizzard; // false
int _ = 1;
// cin >> _;
while (_--)
solve();
return 0;
}
/*
while (l < r)
{
int mid = l + r >> 1;
if (check(mid)) r = mid;
else l = mid + 1;
}
*/
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3716kb
input:
1 1
output:
1
result:
ok single line: '1'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3664kb
input:
1 4
output:
1
result:
ok single line: '1'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3644kb
input:
5 5
output:
3
result:
ok single line: '3'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3660kb
input:
4 4
output:
3
result:
ok single line: '3'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3588kb
input:
3 4
output:
1
result:
ok single line: '1'
Test #6:
score: -100
Wrong Answer
time: 0ms
memory: 3712kb
input:
8 12
output:
7
result:
wrong answer 1st lines differ - expected: '5', found: '7'