QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#511773#9167. Coprime Arrayucup-team3699#WA 0ms3696kbC++201.3kb2024-08-10 10:52:382024-08-10 10:52:38

Judging History

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

  • [2024-08-11 17:38:28]
  • hack成功,自动添加数据
  • (/hack/775)
  • [2024-08-10 10:52:38]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3696kb
  • [2024-08-10 10:52:38]
  • 提交

answer

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define int long long 
#define N 200005
#define pii pair<int, int>
#define F first 
#define S second
int gcd(int a, int b){
    return (b == 0 ? a : gcd(b, a % b));
}
int s, x;
void solve(){
    cin >> s >> x;
    if(gcd(s, x) == 1){
        cout << "1\n";
        cout << s << "\n";
        return;
    }
    for (int i = 1; i <= 1000000; i++){
        // if(i >= 3)
        //     cout << s << " " << x << "\n";
        if(gcd(s - i, x) == 1){
            cout << i + 1 << "\n";
            for (int t = 1; t <= i; t++)
                cout << "1 ";
            cout << s - i << "\n";
            return;
        }
        if(gcd(s + i, x) == 1){
            cout << i + 1 << "\n";
            for (int t = 1; t <= i; t++)
                cout << "-1 ";
            cout << s + i << "\n";
            return;
        }
    }
}
signed main(){
    ios_base::sync_with_stdio(0), cin.tie(0);
    int t = 1;
    // cin >> t;
    while(t--)
        solve();
    return 0;
}
// signed main(){
//     ios_base::sync_with_stdio(0), cin.tie(0);
//     for (s = 2; s <= 100; s++){
//         for (x = 2; x <= 100; x++){
//             // cout << s << " " << x << "\n";
//             solve();
//         }
//     }
//     return 0;
// }

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3620kb

input:

9 6

output:

3
1 1 7

result:

ok Correct

Test #2:

score: 0
Accepted
time: 0ms
memory: 3648kb

input:

14 34

output:

2
1 13

result:

ok Correct

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 3696kb

input:

1000000000 223092870

output:

4
1 1 1 999999997

result:

wrong answer Jury's answer is better than participant's