QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#515779 | #9167. Coprime Array | wsy_jim | AC ✓ | 0ms | 3692kb | C++14 | 1.1kb | 2024-08-12 03:19:44 | 2024-08-12 03:19:44 |
Judging History
answer
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdlib>
#include<ctime>
#include<bitset>
#include<vector>
#include<climits>
#include<iomanip>
using namespace std;
#define N 100010
template<typename T>
inline void read(T &x){
x=0;bool flg=0;char c=getchar();
for(;!isdigit(c);c=getchar()) if(c=='-') flg=1;
for(;isdigit(c);c=getchar()) x=x*10+(c^48);
if(flg) x=-x;
}
int s,x;
int gcd(int a,int b){
return b==0?a:gcd(b,a%b);
}
int main(){
read(s),read(x);
if(gcd(s,x)==1){
cout<<1<<endl;
cout<<s<<endl;
return 0;
}
if(s%2&&(!(x%2))){
int i;
for(i=s-2;;i--){
if(gcd(abs(i),x)==1&&gcd(abs(s-1-i),x)==1) break;
}
cout<<3<<endl;
cout<<1<<" "<<i<<" "<<s-1-i<<endl;
}else{
int i;
for(i=s-1;;i--){
if(gcd(abs(i),x)==1&&gcd(abs(s-i),x)==1) break;
}
cout<<2<<endl;
cout<<i<<" "<<s-i<<endl;
}
return 0;
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3604kb
input:
9 6
output:
3 1 7 1
result:
ok Correct
Test #2:
score: 0
Accepted
time: 0ms
memory: 3692kb
input:
14 34
output:
2 13 1
result:
ok Correct
Test #3:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
1000000000 223092870
output:
2 999999971 29
result:
ok Correct
Test #4:
score: 0
Accepted
time: 0ms
memory: 3604kb
input:
2 1000000000
output:
2 1 1
result:
ok Correct
Test #5:
score: 0
Accepted
time: 0ms
memory: 3692kb
input:
649557664 933437700
output:
2 649557653 11
result:
ok Correct
Test #6:
score: 0
Accepted
time: 0ms
memory: 3564kb
input:
33396678 777360870
output:
2 33396677 1
result:
ok Correct
Test #7:
score: 0
Accepted
time: 0ms
memory: 3532kb
input:
48205845 903124530
output:
3 1 48205813 31
result:
ok Correct
Test #8:
score: 0
Accepted
time: 0ms
memory: 3556kb
input:
251037078 505905400
output:
2 251037077 1
result:
ok Correct
Test #9:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
30022920 172746860
output:
2 30022919 1
result:
ok Correct
Test #10:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
63639298 808058790
output:
2 63639269 29
result:
ok Correct
Test #11:
score: 0
Accepted
time: 0ms
memory: 3568kb
input:
76579017 362768406
output:
3 1 76579015 1
result:
ok Correct
Test #12:
score: 0
Accepted
time: 0ms
memory: 3632kb
input:
40423669 121437778
output:
3 1 40423667 1
result:
ok Correct
Test #13:
score: 0
Accepted
time: 0ms
memory: 3672kb
input:
449277309 720915195
output:
2 449277308 1
result:
ok Correct
Test #14:
score: 0
Accepted
time: 0ms
memory: 3564kb
input:
81665969 919836918
output:
3 1 81665963 5
result:
ok Correct
Test #15:
score: 0
Accepted
time: 0ms
memory: 3684kb
input:
470578680 280387800
output:
2 470578679 1
result:
ok Correct
Test #16:
score: 0
Accepted
time: 0ms
memory: 3536kb
input:
58450340 803305503
output:
2 58450339 1
result:
ok Correct
Test #17:
score: 0
Accepted
time: 0ms
memory: 3536kb
input:
125896113 323676210
output:
3 1 125896081 31
result:
ok Correct
Test #18:
score: 0
Accepted
time: 0ms
memory: 3600kb
input:
381905348 434752500
output:
2 381905347 1
result:
ok Correct
Test #19:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
78916498 653897673
output:
1 78916498
result:
ok Correct
Test #20:
score: 0
Accepted
time: 0ms
memory: 3620kb
input:
35787885 270845190
output:
3 1 35787883 1
result:
ok Correct
Extra Test:
score: 0
Extra Test Passed