QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#519041#9167. Coprime ArrayWWWWJLAC ✓0ms3832kbC++14714b2024-08-14 15:38:522024-08-14 15:38:54

Judging History

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

  • [2024-08-14 15:38:54]
  • 评测
  • 测评结果:AC
  • 用时:0ms
  • 内存:3832kb
  • [2024-08-14 15:38:52]
  • 提交

answer

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

mt19937 rd(time(NULL));

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

void solve(){
	int n,m;
	cin >> n >> m;
	if(gcd(n,m) == 1){
		cout << 1 <<"\n";
		cout << n <<"\n";
		return;
	}
	if((n % 2 == 1) && (m % 2 == 0)){
		cout << 3 <<"\n";
		n -= 1;
		cout << 1 << " ";
	}else{
		cout << 2 <<"\n";
	}
	while(1){
		int x = rd() % n;
		int y = n - x;
		if(gcd(x,m) == 1 && gcd(y,m) == 1){
			cout << x << " " << y <<"\n";
			return;
		}
	}
}

signed main(){
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int t = 1;
    // cin >> t;
    while (t --){
    	solve();
    }
    return 0;
}

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

详细

Test #1:

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

input:

9 6

output:

3
1 1 7

result:

ok Correct

Test #2:

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

input:

14 34

output:

2
7 7

result:

ok Correct

Test #3:

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

input:

1000000000 223092870

output:

2
146662037 853337963

result:

ok Correct

Test #4:

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

input:

2 1000000000

output:

2
1 1

result:

ok Correct

Test #5:

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

input:

649557664 933437700

output:

2
72600677 576956987

result:

ok Correct

Test #6:

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

input:

33396678 777360870

output:

2
18375457 15021221

result:

ok Correct

Test #7:

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

input:

48205845 903124530

output:

3
1 2427883 45777961

result:

ok Correct

Test #8:

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

input:

251037078 505905400

output:

2
67926219 183110859

result:

ok Correct

Test #9:

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

input:

30022920 172746860

output:

2
3499077 26523843

result:

ok Correct

Test #10:

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

input:

63639298 808058790

output:

2
19926311 43712987

result:

ok Correct

Test #11:

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

input:

76579017 362768406

output:

3
1 13349701 63229315

result:

ok Correct

Test #12:

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

input:

40423669 121437778

output:

3
1 23447901 16975767

result:

ok Correct

Test #13:

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

input:

449277309 720915195

output:

2
332975602 116301707

result:

ok Correct

Test #14:

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

input:

81665969 919836918

output:

3
1 38783 81627185

result:

ok Correct

Test #15:

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

input:

470578680 280387800

output:

2
162397643 308181037

result:

ok Correct

Test #16:

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

input:

58450340 803305503

output:

2
50216008 8234332

result:

ok Correct

Test #17:

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

input:

125896113 323676210

output:

3
1 115119109 10777003

result:

ok Correct

Test #18:

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

input:

381905348 434752500

output:

2
327608557 54296791

result:

ok Correct

Test #19:

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

input:

78916498 653897673

output:

1
78916498

result:

ok Correct

Test #20:

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

input:

35787885 270845190

output:

3
1 31055377 4732507

result:

ok Correct

Extra Test:

score: 0
Extra Test Passed