QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#725732#9167. Coprime ArraymaxiaomengWA 47ms3628kbC++141.1kb2024-11-08 19:39:432024-11-08 19:39:44

Judging History

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

  • [2024-11-08 19:39:44]
  • 评测
  • 测评结果:WA
  • 用时:47ms
  • 内存:3628kb
  • [2024-11-08 19:39:43]
  • 提交

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]