QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#725732 | #9167. Coprime Array | maxiaomeng | WA | 47ms | 3628kb | C++14 | 1.1kb | 2024-11-08 19:39:43 | 2024-11-08 19:39:44 |
Judging History
answer
#include<iostream>
#include<time.h>
#include<cstdlib>
#define int long long
using namespace std;
const int inf=1e9,mod=inf-1;
int gcd(int a,int b){
if(b==0)return a;
return gcd(b,a%b);
}
int ca(int a,int b){
return gcd(abs(a),abs(b));
}
signed main(){
srand(time(0));
int s,xe;
cin>>s>>xe;
if(ca(s,xe)==1){
cout<<"1\n"<<s<<"\n";
return 0;
}
for(int i=1;i<=1000000;i++){
int x=rand()+rand()+rand()-rand()-rand();
x%=mod;
int y=s-x;
if(abs(x)>inf || abs(y)>inf)continue;
if(ca(x,xe)!=1 || ca(y,xe)!=1)continue;
cout<<2<<"\n"<<x<<" "<<y<<"\n";
return 0;
}
for(int i=1;i<=1000000;i++){
int x=rand()+rand()+rand()-rand()-rand();
int y=rand()-rand()+rand()-rand()+rand();
cout<<x<<" "<<y<<endl;
int z=s-x-y;
if(abs(x)>inf || abs(y)>inf || abs(z)>inf)continue;
if(ca(x,xe)!=1 || ca(y,xe)!=1 || ca(z,xe)!=1)continue;
cout<<3<<"\n"<<x<<" "<<y<<" "<<z<<"\n";
return 0;
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 47ms
memory: 3628kb
input:
9 6
output:
-1246353810 1299043434 -742827763 -1994152554 -854240405 712760220 334142343 -1746466452 -1599060354 1016968 183937582 68981790 93883032 816578332 2071768551 68964221 1735551877 2112225563 716556089 -1412660648 -987385836 -1476540749 2110734357 1109362639 -359132728 -906284330 1920652394 728693459 1...
result:
wrong answer Integer parameter [name=n] equals to -1246353810, violates the range [-1, 1000000]