QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#512326#9167. Coprime Arrayucup-team3661#AC ✓69ms3716kbC++20759b2024-08-10 14:09:142024-10-14 07:51:58

Judging History

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

  • [2024-10-14 07:51:58]
  • 管理员手动重测本题所有获得100分的提交记录
  • 测评结果:AC
  • 用时:69ms
  • 内存:3716kb
  • [2024-08-11 17:38:28]
  • hack成功,自动添加数据
  • (/hack/775)
  • [2024-08-10 14:09:14]
  • 评测
  • 测评结果:100
  • 用时:70ms
  • 内存:3688kb
  • [2024-08-10 14:09:14]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

int main(){
	int s, x;
	cin >> s >> x;
	if(gcd(s, x) == 1){
		cout << 1 << endl;
		cout << s << endl;
		return 0;
	}
	if(s % 2 == 1 && x % 2 == 0){
		cout << 3 << endl;
		for(int i = -(1<<20); i <= (1<<20); ++i){
			if(gcd(abs(i), abs(x)) != 1) continue;
			if(s-i-i > 1000000000) continue;
			if(gcd(abs(s-i-i), abs(x)) == 1){
				cout << i << ' ' << i << ' ' << s-i-i << endl;
				return 0;
			}
		}
	}else{
		cout << 2 << endl;
		for(int i = -(1<<20); i <= (1<<20); ++i){
			if(gcd(abs(i), abs(x)) != 1) continue;
			if(s-i > 1000000000) continue;
			if(gcd(abs(s-i), abs(x)) == 1){
				cout << i << ' ' << s-i << endl;
				return 0;
			}
		}
	}
	assert(false);
	return 0;
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3568kb

input:

9 6

output:

3
-1048573 -1048573 2097155

result:

ok Correct

Test #2:

score: 0
Accepted
time: 0ms
memory: 3628kb

input:

14 34

output:

2
-1048575 1048589

result:

ok Correct

Test #3:

score: 0
Accepted
time: 69ms
memory: 3616kb

input:

1000000000 223092870

output:

2
29 999999971

result:

ok Correct

Test #4:

score: 0
Accepted
time: 0ms
memory: 3560kb

input:

2 1000000000

output:

2
-1048571 1048573

result:

ok Correct

Test #5:

score: 0
Accepted
time: 0ms
memory: 3632kb

input:

649557664 933437700

output:

2
-1048573 650606237

result:

ok Correct

Test #6:

score: 0
Accepted
time: 0ms
memory: 3628kb

input:

33396678 777360870

output:

2
-1048573 34445251

result:

ok Correct

Test #7:

score: 0
Accepted
time: 0ms
memory: 3568kb

input:

48205845 903124530

output:

3
-1048573 -1048573 50302991

result:

ok Correct

Test #8:

score: 0
Accepted
time: 0ms
memory: 3632kb

input:

251037078 505905400

output:

2
-1048573 252085651

result:

ok Correct

Test #9:

score: 0
Accepted
time: 0ms
memory: 3700kb

input:

30022920 172746860

output:

2
-1048573 31071493

result:

ok Correct

Test #10:

score: 0
Accepted
time: 0ms
memory: 3568kb

input:

63639298 808058790

output:

2
-1048573 64687871

result:

ok Correct

Test #11:

score: 0
Accepted
time: 0ms
memory: 3640kb

input:

76579017 362768406

output:

3
-1048573 -1048573 78676163

result:

ok Correct

Test #12:

score: 0
Accepted
time: 0ms
memory: 3716kb

input:

40423669 121437778

output:

3
-1048573 -1048573 42520815

result:

ok Correct

Test #13:

score: 0
Accepted
time: 0ms
memory: 3700kb

input:

449277309 720915195

output:

2
-1048573 450325882

result:

ok Correct

Test #14:

score: 0
Accepted
time: 0ms
memory: 3636kb

input:

81665969 919836918

output:

3
-1048573 -1048573 83763115

result:

ok Correct

Test #15:

score: 0
Accepted
time: 0ms
memory: 3644kb

input:

470578680 280387800

output:

2
-1048573 471627253

result:

ok Correct

Test #16:

score: 0
Accepted
time: 0ms
memory: 3708kb

input:

58450340 803305503

output:

2
-1048574 59498914

result:

ok Correct

Test #17:

score: 0
Accepted
time: 0ms
memory: 3644kb

input:

125896113 323676210

output:

3
-1048573 -1048573 127993259

result:

ok Correct

Test #18:

score: 0
Accepted
time: 0ms
memory: 3580kb

input:

381905348 434752500

output:

2
-1048571 382953919

result:

ok Correct

Test #19:

score: 0
Accepted
time: 0ms
memory: 3632kb

input:

78916498 653897673

output:

1
78916498

result:

ok Correct

Test #20:

score: 0
Accepted
time: 0ms
memory: 3648kb

input:

35787885 270845190

output:

3
-1048567 -1048567 37885019

result:

ok Correct

Extra Test:

score: 0
Extra Test Passed