QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#592232#9167. Coprime ArrayD06AC ✓0ms3724kbC++14882b2024-09-26 21:20:252024-09-26 21:20:26

Judging History

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

  • [2024-09-26 21:20:26]
  • 评测
  • 测评结果:AC
  • 用时:0ms
  • 内存:3724kb
  • [2024-09-26 21:20:25]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
int d;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int s,x;
	cin>>s>>x;
	if(__gcd(s,x)==1)
	{
		cout<<1<<endl;
		cout<<s<<endl;
	}
	else
	{
		d=s/x*x;
		s%=x;
		int tmp=0,len=2;
		if(s%2==1&&x%2==0)
		{
			tmp=1+d;
			len++;
			s--;
			d=0;
		}
		int y,z;
		while(1)
		{
			y=rand()%(x+1);
			if(__gcd(y,x)==1&&abs(__gcd(s-y,x))==1)
			{
				z=s-y;
				y=y+d;
				if(y>1000000000)
				{
					z=z+(y-1000000000)/x*x;
					y=y-(y-1000000000)/x*x;
					if(y>1000000000)
					{
						y-=x;
						z+=x;
					}
					if(z>1000000000)
					{
						cout<<-1<<endl;
						return 0;
					}
				}
				cout<<len<<endl;
				if(len==2)
				{
					cout<<y<<" "<<z<<endl;
				}
				else
				{
					cout<<tmp<<" "<<y<<" "<<z<<endl;
				}
				return 0;
			}
		}
	}
	return 0;
}

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

9 6

output:

3
7 1 1

result:

ok Correct

Test #2:

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

input:

14 34

output:

2
11 3

result:

ok Correct

Test #3:

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

input:

1000000000 223092870

output:

2
857269991 142730009

result:

ok Correct

Test #4:

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

input:

2 1000000000

output:

2
649760491 -649760489

result:

ok Correct

Test #5:

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

input:

649557664 933437700

output:

2
35005211 614552453

result:

ok Correct

Test #6:

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

input:

33396678 777360870

output:

2
587819669 -554422991

result:

ok Correct

Test #7:

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

input:

48205845 903124530

output:

3
1 233665123 -185459279

result:

ok Correct

Test #8:

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

input:

251037078 505905400

output:

2
177830619 73206459

result:

ok Correct

Test #9:

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

input:

30022920 172746860

output:

2
78744613 -48721693

result:

ok Correct

Test #10:

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

input:

63639298 808058790

output:

2
35005211 28634087

result:

ok Correct

Test #11:

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

input:

76579017 362768406

output:

3
1 233665123 -157086107

result:

ok Correct

Test #12:

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

input:

40423669 121437778

output:

3
1 104160477 -63736809

result:

ok Correct

Test #13:

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

input:

449277309 720915195

output:

2
304089172 145188137

result:

ok Correct

Test #14:

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

input:

81665969 919836918

output:

3
1 729923573 -648257605

result:

ok Correct

Test #15:

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

input:

470578680 280387800

output:

2
286155283 184423397

result:

ok Correct

Test #16:

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

input:

58450340 803305503

output:

2
424238335 -365787995

result:

ok Correct

Test #17:

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

input:

125896113 323676210

output:

3
1 12789571 113106541

result:

ok Correct

Test #18:

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

input:

381905348 434752500

output:

2
218737789 163167559

result:

ok Correct

Test #19:

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

input:

78916498 653897673

output:

1
78916498

result:

ok Correct

Test #20:

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

input:

35787885 270845190

output:

3
1 34395313 1392571

result:

ok Correct

Extra Test:

score: 0
Extra Test Passed