UOJ Logo

NOI.AC

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#190868#1. A+B ProblemJxkcy1000ms1252kbC++562b2023-10-07 18:44:082023-10-07 18:44:09

answer

#include <bits/stdc++.h>
using namespace std;
int a[3],n=2,x;
int b[3];//差分数组
int c[3];//树状数组
inline int lowbit(int x){
	return x & (-x);
}
inline void add(int p,int k){
	while(p <= n){
		c[p] += k;
		p += lowbit(p);
	}
}
inline int count(int p){
	int res = 0;
	while(p >= 1){
		res += c[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 >> a[i];
		b[i]=a[i]-a[i-1];
		add(i,b[i]);
	}
	cout << count(1) + count(2);
	return 0;
}

Details

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

Test #1:

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

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: 0ms
memory: 1252kb

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: 1248kb

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: 1248kb

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