QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#743973#9597. Grade 2xdz_#WA 0ms3628kbC++201.2kb2024-11-13 20:29:062024-11-13 20:29:07

Judging History

你现在查看的是最新测评结果

  • [2024-11-13 20:29:07]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3628kb
  • [2024-11-13 20:29:06]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second

int gcd(int a,int b){
	return b ? gcd(b,a % b) : a;
}

void solve(){
	int x,n;
	cin >>x>>n;
	vector<int> s(x + 2);
	int sum1 = 0;
	for(int i = 1;i <= x + 1;i ++){
		int z = (i * x) ^ x;
		int z1 = gcd(z,x);
		if(z1 == 1){
			s[i] = s[i - 1] + 1;
		}
		else s[i] = s[i - 1];
	}
	for(int i = 1;i <= 100;i ++){
		int z = (i * x) ^ x;
		int z1 = gcd(z,x);
		cout<<z<<' '<<z1<<'\n';
	}
	for(int i = 1;i <= n;i ++){
		int l,r;
		cin >>l>>r;
		int sum = 0;
		if(l % (x + 1) == 0){
			l ++;
			sum += s[x + 1] - s[x];
		}
		if(l > r){
			cout<<s[x + 1] - s[x]<<'\n';
			continue;
		}
		if(r <= l + ((x + 1) - (l % (x + 1)))){
			cout<<s[r % (x + 1)] - s[(l % (x + 1)) - 1]<<'\n';
			continue;
		}
		int z = l % (x + 1);
		int z1 = r % (x + 1);
		r -= r % (x + 1);
		l += ((x + 1) - (l % (x + 1)));
		sum = ((r - l) / (x + 1)) * s[x + 1];
		sum += s[(x + 1)] - s[z - 1];
		sum += s[z1] - s[0];
		cout<<sum<<'\n';
	}
}

signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int T;
	T = 1;
	while(T --){
		solve();
	}
} 

詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3628kb

input:

15 2
1 4
11 4514

output:

0 15
17 1
34 1
51 3
68 1
85 5
102 3
119 1
136 1
153 3
170 5
187 1
204 3
221 1
238 1
255 15
240 15
257 1
274 1
291 3
308 1
325 5
342 3
359 1
376 1
393 3
410 5
427 1
444 3
461 1
478 1
495 15
480 15
497 1
514 1
531 3
548 1
565 5
582 3
599 1
616 1
633 3
650 5
667 1
684 3
701 1
718 1
735 15
720 15
737 1
...

result:

wrong answer 1st lines differ - expected: '2', found: '0 15'