ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#206123 | #1. A+B Problem | zhuanger | 100 | 0ms | 1136kb | C++ | 1.9kb | 2024-07-20 20:10:55 | 2024-07-20 20:10:58 |
answer
#define LOCAL
#include <bits/extc++.h>
#include <bits/stdc++.h>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#define int long long
using namespace __gnu_pbds;
using namespace __gnu_cxx;
using namespace std;
int sum[1000], a[1000];
namespace ly {
namespace IO {
#ifndef LOCAL
#define SIZE (1 << 20)
char in[SIZE], out[SIZE], *p1 = in, *p2 = in, *p3 = out;
#define getchar() \
(p1 == p2 && (p2 = (p1 = in) + fread(in, 1, SIZE, stdin), p1 == p2) ? EOF \
: *p1++)
#define flush() (fwrite(p3 = out, 1, SIZE, stdout))
#define putchar(ch) (p3 == out + SIZE && flush(), *p3++ = (ch))
class Flush {
public:
~Flush() { flush(); }
} _;
#endif
template <typename type>
inline void read(type &x) {
x = 0;
bool flag(0);
char ch = getchar();
while (!isdigit(ch)) flag ^= ch == '-', ch = getchar();
while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
flag ? x = -x : 0;
}
template <typename type>
inline void write(type x, bool flag = 1) {
x < 0 ? x = -x, putchar('-') : 0;
static int Stack[50], top(0);
do
Stack[++top] = x % 10, x /= 10;
while (x);
while (top) putchar(Stack[top--] | 48);
flag ? putchar('\n') : putchar(' ');
}
#ifndef LOCAL
#undef SIZE
#undef getchar
#undef putchar
#undef flush
#endif
} // namespace IO
} // namespace ly
using namespace ly::IO;
inline int lowbit(const int &x) { return x & (~x + 1); }
inline void add(int p, const int &x) {
for (register int i = 1; i < 3; i += lowbit(i)) sum[i] += x;
}
inline int ask(int p) {
int res = 0;
for (register int i = p; i; i -= lowbit(i)) res += sum[p];
return res;
}
signed main() {
read(a[1]);
read(a[2]);
for (register int i = 1; i < 3; i = (i | 1) + (i & 1)) add(i, a[i]);
write(ask(2));
return 0;
}
详细
小提示:点击横条可展开更详细的信息
Test #1:
score: 10
Accepted
time: 0ms
memory: 1136kb
input:
23 24
output:
47
result:
ok single line: '47'
Test #2:
score: 10
Accepted
time: 0ms
memory: 1132kb
input:
233 1
output:
234
result:
ok single line: '234'
Test #3:
score: 10
Accepted
time: 0ms
memory: 1136kb
input:
222 333
output:
555
result:
ok single line: '555'
Test #4:
score: 10
Accepted
time: 0ms
memory: 1132kb
input:
1 333
output:
334
result:
ok single line: '334'
Test #5:
score: 10
Accepted
time: 0ms
memory: 1132kb
input:
222 333
output:
555
result:
ok single line: '555'
Test #6:
score: 10
Accepted
time: 0ms
memory: 1136kb
input:
242 333
output:
575
result:
ok single line: '575'
Test #7:
score: 10
Accepted
time: 0ms
memory: 1132kb
input:
222 3330
output:
3552
result:
ok single line: '3552'
Test #8:
score: 10
Accepted
time: 0ms
memory: 1132kb
input:
2220 333
output:
2553
result:
ok single line: '2553'
Test #9:
score: 10
Accepted
time: 0ms
memory: 1132kb
input:
222 555
output:
777
result:
ok single line: '777'
Test #10:
score: 10
Accepted
time: 0ms
memory: 1136kb
input:
222 3333
output:
3555
result:
ok single line: '3555'
Extra Test:
score: 0
Extra Test Passed