QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#519038 | #9167. Coprime Array | WWWWJL | WA | 0ms | 3800kb | C++14 | 714b | 2024-08-14 15:37:59 | 2024-08-14 15:37:59 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
using namespace std;
mt19937 rd(time(NULL));
int gcd(int a,int b){
return b == 0 ? a : gcd(b,a % b);
}
void solve(){
int n,m;
cin >> n >> m;
if(gcd(n,m) == 1){
cout << 1 <<"\n";
cout << n <<"\n";
return;
}
if((n % 2 == 1) && (m % 2 == 0)){
cout << 3 <<"\n";
n -= 1;
cout << 1 << " ";
}else{
cout << 2 <<"\n";
}
while(1){
int x = rd() % n;
int y = n - x;
if(gcd(x,n) == 1 && gcd(y,n) == 1){
cout << x << " " << y <<"\n";
return;
}
}
}
signed main(){
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
int t = 1;
// cin >> t;
while (t --){
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3800kb
input:
9 6
output:
3 1 3 5
result:
wrong answer Element at position 2 is not coprime to x