QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#516102#9167. Coprime Arraynahida_qaqAC ✓0ms3772kbC++17706b2024-08-12 13:44:462024-08-12 13:44:48

Judging History

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

  • [2024-08-12 13:44:48]
  • 评测
  • 测评结果:AC
  • 用时:0ms
  • 内存:3772kb
  • [2024-08-12 13:44:46]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long
#define io ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define pb push_back
using namespace std;
const int N=1e6+5,mod1=1e9+7,mod2=998244353;
typedef pair<int,int> pi;
int a[N];
mt19937_64 rng(time(0));
void solve()
{
	int s,x;
	cin>>s>>x;
	if(gcd(s,x)==1)
	{
		cout<<1<<'\n';
		cout<<s;
		return ;
	}
	else if(s%2==1&&x%2==0)
	{
		cout<<3<<'\n';
		cout<<1<<' ';
		s--;
	}
	else cout<<2<<'\n';
	while(1)
	{
		int a=rng()%(1000000000+1);
		int b=s-a;
		if(gcd(x,a)==1&&gcd(x,b)==1)
		{
			cout<<a<<' '<<b;
			return ;
		}
	}
}
signed main()
{
	io;
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}

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

详细

Test #1:

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

input:

9 6

output:

3
1 628273345 -628273337

result:

ok Correct

Test #2:

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

input:

14 34

output:

2
628273345 -628273331

result:

ok Correct

Test #3:

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

input:

1000000000 223092870

output:

2
726939281 273060719

result:

ok Correct

Test #4:

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

input:

2 1000000000

output:

2
726939281 -726939279

result:

ok Correct

Test #5:

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

input:

649557664 933437700

output:

2
726939281 -77381617

result:

ok Correct

Test #6:

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

input:

33396678 777360870

output:

2
602702029 -569305351

result:

ok Correct

Test #7:

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

input:

48205845 903124530

output:

3
1 136226053 -88020209

result:

ok Correct

Test #8:

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

input:

251037078 505905400

output:

2
862504917 -611467839

result:

ok Correct

Test #9:

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

input:

30022920 172746860

output:

2
726939281 -696916361

result:

ok Correct

Test #10:

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

input:

63639298 808058790

output:

2
726939281 -663299983

result:

ok Correct

Test #11:

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

input:

76579017 362768406

output:

3
1 136226053 -59647037

result:

ok Correct

Test #12:

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

input:

40423669 121437778

output:

3
1 354595475 -314171807

result:

ok Correct

Test #13:

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

input:

449277309 720915195

output:

2
235748806 213528503

result:

ok Correct

Test #14:

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

input:

81665969 919836918

output:

3
1 726939281 -645273313

result:

ok Correct

Test #15:

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

input:

470578680 280387800

output:

2
983799203 -513220523

result:

ok Correct

Test #16:

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

input:

58450340 803305503

output:

2
541978180 -483527840

result:

ok Correct

Test #17:

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

input:

125896113 323676210

output:

3
1 136226053 -10329941

result:

ok Correct

Test #18:

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

input:

381905348 434752500

output:

2
90366889 291538459

result:

ok Correct

Test #19:

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

input:

78916498 653897673

output:

1
78916498

result:

ok Correct

Test #20:

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

input:

35787885 270845190

output:

3
1 136226053 -100438169

result:

ok Correct

Extra Test:

score: 0
Extra Test Passed