QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#543369#9167. Coprime Arraycode_side-effectWA 0ms3752kbC++201.1kb2024-09-01 16:19:182024-09-01 16:19:19

Judging History

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

  • [2024-09-01 16:19:19]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3752kb
  • [2024-09-01 16:19:18]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define pi 3.14159265358979323846
#define int long long
const int inf = 1e9;
const int MOD = 998244353;
const int N = 200005;
std:: mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void solve()
{
    int s,x;
    cin >> s >> x;
    if(__gcd(s,x) == 1){
        cout << 1 << "\n";
        cout << s ;
        return ; 
    }
    if(s % 2 == 1){
        cout << 3 << "\n";
        cout << 1 << " ";
        s--;
    }
    else cout << 2 << "\n";
    while(true){
        int a = inf - rng() % x;
        int b = s - a;
        if(b < -inf){
            int t = -(inf + b);
            t = (t + x - 1) / x*x;
            a+=t;
            b-=t;
        }
        if(abs(a) > inf || abs(b) > inf || __gcd(a,x) != 1 || __gcd(b,x) != 1){
            continue;
        }
        cout << a << " " << b << "\n";
        return ;
    }
   
}


signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
   // cin >> t;
    while (t--)
    {
        solve();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

9 6

output:

3
1 999999997 -999999989

result:

ok Correct

Test #2:

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

input:

14 34

output:

2
999999999 -999999985

result:

ok Correct

Test #3:

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

input:

1000000000 223092870

output:

2
913608491 86391509

result:

ok Correct

Test #4:

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

input:

2 1000000000

output:

2
937384859 -937384857

result:

ok Correct

Test #5:

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

input:

649557664 933437700

output:

2
183565433 465992231

result:

ok Correct

Test #6:

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

input:

33396678 777360870

output:

2
247910749 -214514071

result:

ok Correct

Test #7:

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

input:

48205845 903124530

output:

3
1 603157501 -554951657

result:

ok Correct

Test #8:

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

input:

251037078 505905400

output:

2
604396921 -353359843

result:

ok Correct

Test #9:

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

input:

30022920 172746860

output:

2
949945083 -919922163

result:

ok Correct

Test #10:

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

input:

63639298 808058790

output:

2
627372491 -563733193

result:

ok Correct

Test #11:

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

input:

76579017 362768406

output:

3
1 957129343 -880550327

result:

ok Correct

Test #12:

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

input:

40423669 121437778

output:

3
1 888515531 -848091863

result:

ok Correct

Test #13:

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

input:

449277309 720915195

output:

3
1 403178161 46099147

result:

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