QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#515607#9167. Coprime ArrayqqbbAC ✓310ms11176kbC++201.5kb2024-08-11 19:14:432024-08-11 19:14:45

Judging History

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

  • [2024-08-11 19:14:45]
  • 评测
  • 测评结果:AC
  • 用时:310ms
  • 内存:11176kb
  • [2024-08-11 19:14:43]
  • 提交

answer

// https://qoj.ac/contest/1762/problem/9167
#include <bits/stdc++.h>
#define qqbb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define all(x) (x).begin(), (x).end()
#define int long long
#define endl '\n'
#define lb(x) x & -x
#define AA cerr<<"AA"<<endl;
using namespace std;
typedef pair<int, int> pii;
const int inf = 0x3f3f3f3f;

const int N = 2e5 + 10, M = 4e5 + 10;

void solve(){
    int n,m;cin>>n>>m;
    if(__gcd(n,m) == 1){
        cout<<1<<endl<<n;
        return;
    }
    vector<array<int,3>> ans;
    for(int i = -1000;i <= 1000; i++){
        for(int j = 1;j <= 1000; j++){
            int k = n - i - j;
            if(abs(k) >= 1e9) continue;
            int f1 = 0,f2 = 0,f3 = 0;
            if(i == 0 || __gcd(i,m) == 1){
                f1 = 1;
            }
            if(j == 0 || __gcd(j,m) == 1){
                f2 = 1;
            }
            if(k == 0 || __gcd(k,m) == 1){
                f3 = 1;
            }
            if(f1 && f2 && f3){
                ans.push_back({i,j,k});
            }
        }
    }
    for(auto [x,y,z] : ans){
        if(x == 0 || y == 0 || z == 0){
            cout<<2<<endl;
            if(x == 0) cout<<y<<' '<<z;
            else if(y == 0) cout<<x<<' '<<z;
            else cout<<x<<' '<<y;
            return;
        }
    }
    cout<<3<<endl;
    cout<<ans[0][0]<<' '<<ans[0][1]<<' '<<ans[0][2];
}

signed main(){
    qqbb;
//	cout<<fixed<<setprecision(0);
    int Test=1;
//	cin>>Test;
    while(Test--){
        solve();
    }
    return 0;
}

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

详细

Test #1:

score: 100
Accepted
time: 39ms
memory: 4848kb

input:

9 6

output:

3
-995 1 1003

result:

ok Correct

Test #2:

score: 0
Accepted
time: 74ms
memory: 3772kb

input:

14 34

output:

2
-985 999

result:

ok Correct

Test #3:

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

input:

1000000000 223092870

output:

2
29 999999971

result:

ok Correct

Test #4:

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

input:

2 1000000000

output:

2
-989 991

result:

ok Correct

Test #5:

score: 0
Accepted
time: 277ms
memory: 3616kb

input:

649557664 933437700

output:

2
11 649557653

result:

ok Correct

Test #6:

score: 0
Accepted
time: 296ms
memory: 3556kb

input:

33396678 777360870

output:

2
1 33396677

result:

ok Correct

Test #7:

score: 0
Accepted
time: 294ms
memory: 3708kb

input:

48205845 903124530

output:

3
-991 23 48206813

result:

ok Correct

Test #8:

score: 0
Accepted
time: 261ms
memory: 3792kb

input:

251037078 505905400

output:

2
1 251037077

result:

ok Correct

Test #9:

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

input:

30022920 172746860

output:

2
1 30022919

result:

ok Correct

Test #10:

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

input:

63639298 808058790

output:

2
29 63639269

result:

ok Correct

Test #11:

score: 0
Accepted
time: 286ms
memory: 4032kb

input:

76579017 362768406

output:

3
-997 23 76579991

result:

ok Correct

Test #12:

score: 0
Accepted
time: 256ms
memory: 11176kb

input:

40423669 121437778

output:

3
-997 1 40424665

result:

ok Correct

Test #13:

score: 0
Accepted
time: 310ms
memory: 4780kb

input:

449277309 720915195

output:

2
1 449277308

result:

ok Correct

Test #14:

score: 0
Accepted
time: 291ms
memory: 4800kb

input:

81665969 919836918

output:

3
-997 1 81666965

result:

ok Correct

Test #15:

score: 0
Accepted
time: 277ms
memory: 3536kb

input:

470578680 280387800

output:

2
1 470578679

result:

ok Correct

Test #16:

score: 0
Accepted
time: 300ms
memory: 10696kb

input:

58450340 803305503

output:

2
1 58450339

result:

ok Correct

Test #17:

score: 0
Accepted
time: 280ms
memory: 4056kb

input:

125896113 323676210

output:

3
-989 31 125897071

result:

ok Correct

Test #18:

score: 0
Accepted
time: 290ms
memory: 3812kb

input:

381905348 434752500

output:

2
1 381905347

result:

ok Correct

Test #19:

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

input:

78916498 653897673

output:

1
78916498

result:

ok Correct

Test #20:

score: 0
Accepted
time: 274ms
memory: 3684kb

input:

35787885 270845190

output:

3
-997 29 35788853

result:

ok Correct

Extra Test:

score: 0
Extra Test Passed