QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#543372#9167. Coprime Arraycode_side-effectAC ✓0ms3744kbC++201.1kb2024-09-01 16:21:352024-09-01 16:21:37

Judging History

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

  • [2024-09-01 16:21:37]
  • 评测
  • 测评结果:AC
  • 用时:0ms
  • 内存:3744kb
  • [2024-09-01 16:21:35]
  • 提交

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 && x % 2 == 0){
        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();
    }
}

这程序好像有点Bug,我给组数据试试?

詳細信息

Test #1:

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

input:

9 6

output:

3
1 999999997 -999999989

result:

ok Correct

Test #2:

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

input:

14 34

output:

2
999999999 -999999985

result:

ok Correct

Test #3:

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

input:

1000000000 223092870

output:

2
892502573 107497427

result:

ok Correct

Test #4:

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

input:

2 1000000000

output:

2
170492389 -170492387

result:

ok Correct

Test #5:

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

input:

649557664 933437700

output:

2
594443363 55114301

result:

ok Correct

Test #6:

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

input:

33396678 777360870

output:

2
753622049 -720225371

result:

ok Correct

Test #7:

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

input:

48205845 903124530

output:

3
1 727194943 -678989099

result:

ok Correct

Test #8:

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

input:

251037078 505905400

output:

2
746067177 -495030099

result:

ok Correct

Test #9:

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

input:

30022920 172746860

output:

2
870573801 -840550881

result:

ok Correct

Test #10:

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

input:

63639298 808058790

output:

2
355307069 -291667771

result:

ok Correct

Test #11:

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

input:

76579017 362768406

output:

3
1 865138387 -788559371

result:

ok Correct

Test #12:

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

input:

40423669 121437778

output:

3
1 956437919 -916014251

result:

ok Correct

Test #13:

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

input:

449277309 720915195

output:

2
290129066 159148243

result:

ok Correct

Test #14:

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

input:

81665969 919836918

output:

3
1 870089081 -788423113

result:

ok Correct

Test #15:

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

input:

470578680 280387800

output:

2
935639681 -465061001

result:

ok Correct

Test #16:

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

input:

58450340 803305503

output:

2
744119659 -685669319

result:

ok Correct

Test #17:

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

input:

125896113 323676210

output:

3
1 869228209 -743332097

result:

ok Correct

Test #18:

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

input:

381905348 434752500

output:

2
887422189 -505516841

result:

ok Correct

Test #19:

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

input:

78916498 653897673

output:

1
78916498

result:

ok Correct

Test #20:

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

input:

35787885 270845190

output:

3
1 933565063 -897777179

result:

ok Correct

Extra Test:

score: 0
Extra Test Passed