QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#512029#9167. Coprime Arrayucup-team956#WA 0ms3644kbC++20882b2024-08-10 13:19:412024-08-10 13:19:42

Judging History

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

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

answer

#include<bits/stdc++.h>
using namespace std;
#define time chrono::system_clock::now().time_since_epoch().count()
mt19937_64 rnd(time);
#define maxn 1000005
#define int long long

int read() {int x;cin>>x;return x;}

void solve() {
    int n = read(), s = read();
    if(__gcd(n, s) == 1) {
        cout << 1 << "\n" << n << "\n";
    }
    else if(__gcd(n + 1, s) == 1 || __gcd(n - 1, s) == 1) {
        cout << 2 << "\n";
        if(__gcd(n + 1, s) == 1) cout << n + 1 << " " << -1 << "\n";
        else cout << n - 1 << " " << 1 << "\n";
    }
    else {
        cout << 3 << "\n";
        cout << n - 2 << " " << 1 << " " << 1 << "\n"; 
    }
}

signed main() {
    #ifdef ONLINE_JUDGE
        ios::sync_with_stdio(false);
        cin.tie(0);cout.tie(0);
    #else
        //freopen("a.in", "r", stdin);
    #endif

    solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

9 6

output:

3
7 1 1

result:

ok Correct

Test #2:

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

input:

14 34

output:

2
15 -1

result:

ok Correct

Test #3:

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

input:

1000000000 223092870

output:

3
999999998 1 1

result:

wrong answer Element at position 1 is not coprime to x