UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#190792#1. A+B ProblemJxkcy1002ms1252kbC++474b2023-10-07 18:14:452023-10-07 18:14:46

answer

#include <bits/stdc++.h>
using namespace std;
int a[3],n=2,x;
inline int lowbit(int x){
	return x & (-x);
}
inline void add(int p,int k){
	while(p <= n){
		a[p] += k;
		p += lowbit(p);
	}
}
inline int count(int p){
	int res = 0;
	while(p >= 1){
		res += a[p];
		p -= lowbit(p);
	}
	return res;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	for(int i=1;i<=n;i++){
		cin >> x;
		add(i,x);
	}
	cout << count(n);
	return 0;
}

详细

小提示:点击横条可展开更详细的信息

Test #1:

score: 10
Accepted
time: 1ms
memory: 1252kb

input:

23 24

output:

47

result:

ok 1 number(s): "47"

Test #2:

score: 10
Accepted
time: 0ms
memory: 1252kb

input:

233 1

output:

234

result:

ok 1 number(s): "234"

Test #3:

score: 10
Accepted
time: 1ms
memory: 1248kb

input:

222 333

output:

555

result:

ok 1 number(s): "555"

Test #4:

score: 10
Accepted
time: 0ms
memory: 1252kb

input:

1 333

output:

334

result:

ok 1 number(s): "334"

Test #5:

score: 10
Accepted
time: 0ms
memory: 1252kb

input:

222 333

output:

555

result:

ok 1 number(s): "555"

Test #6:

score: 10
Accepted
time: 0ms
memory: 1252kb

input:

242 333

output:

575

result:

ok 1 number(s): "575"

Test #7:

score: 10
Accepted
time: 0ms
memory: 1252kb

input:

222 3330

output:

3552

result:

ok 1 number(s): "3552"

Test #8:

score: 10
Accepted
time: 0ms
memory: 1252kb

input:

2220 333

output:

2553

result:

ok 1 number(s): "2553"

Test #9:

score: 10
Accepted
time: 0ms
memory: 1252kb

input:

222 555

output:

777

result:

ok 1 number(s): "777"

Test #10:

score: 10
Accepted
time: 0ms
memory: 1252kb

input:

222 3333

output:

3555

result:

ok 1 number(s): "3555"

Extra Test:

score: 0
Extra Test Passed