QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#722904 | #9167. Coprime Array | xieliren | TL | 0ms | 0kb | C++14 | 842b | 2024-11-07 20:33:17 | 2024-11-07 20:33:17 |
answer
#include<bits/stdc++.h>
using namespace std;
int read(){
int s = 0, f = 1;char ch = getchar();
while(!isdigit(ch)){if(ch == '-')f = -1;ch = getchar();}
while(isdigit(ch)){s = s * 10 + ch - '0';ch = getchar();}
return s * f;
}
void write(int x){
if(x < 0){putchar('-'); x = -x;}
if(x > 9) write(x / 10);
putchar(x % 10 + '0');
}
int main(){
int n = read(), m = read();
if(__gcd(n, m) == 1){
printf("1\n%d", n);
return 0;
}
if(m % 2 == 0 && n % 2 == 1){
for(int i = 3e8;;i --){
int h = n - i * 2;
if(__gcd(h, m) == 1 && __gcd(-i, m) == 1){
printf("3\n%d %d %d\n", i, i, h);
return 0;
}
}
}
else{
for(int i = 5e8;;i --){
int h = n - i;
if(__gcd(h, m) == 1 && __gcd(-i, m) == 1){
printf("2\n%d %d\n", i, h);
return 0;
}
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Time Limit Exceeded
input:
9 6