QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#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;
}
详细
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