QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#511985#9167. Coprime Arrayucup-team045#AC ✓0ms3820kbC++20973b2024-08-10 13:10:352024-10-14 07:51:48

Judging History

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

  • [2024-10-14 07:51:48]
  • 管理员手动重测本题所有获得100分的提交记录
  • 测评结果:AC
  • 用时:0ms
  • 内存:3820kb
  • [2024-08-11 17:38:28]
  • hack成功,自动添加数据
  • (/hack/775)
  • [2024-08-10 13:10:35]
  • 评测
  • 测评结果:100
  • 用时:0ms
  • 内存:3824kb
  • [2024-08-10 13:10:35]
  • 提交

answer

#include<iostream>
#include<cstring>
#include<vector>
#include<numeric>
#include<cassert>
using namespace std;
using LL = long long;

int main(){

#ifdef LOCAL
    freopen("data.in", "r", stdin);
    freopen("data.out", "w", stdout);
#endif

    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(0);

    int s, x;
    cin >> s >> x;

    auto get = [&](auto &&get, int s, int x) -> vector<int> {
        if (gcd(s, x) == 1) return {s};
        if (x % 2 == 0 and s % 2 != 0){
            auto ans = get(get, s + 1, x);
            ans.push_back(-1);
            return ans;
        }
        for(int i = 1; ; i++){
            if (gcd(i, x) == 1 and gcd(abs(s - i), x) == 1){
                vector<int> ans{i, s - i};
                return ans;
            }
        }
        assert(false);
    };

    auto ans = get(get, s, x);
    cout << ans.size() << '\n';
    for(auto x : ans) cout << x << ' ';
    cout << '\n';

}

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

詳細信息

Test #1:

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

input:

9 6

output:

3
5 5 -1 

result:

ok Correct

Test #2:

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

input:

14 34

output:

2
1 13 

result:

ok Correct

Test #3:

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

input:

1000000000 223092870

output:

2
29 999999971 

result:

ok Correct

Test #4:

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

input:

2 1000000000

output:

2
1 1 

result:

ok Correct

Test #5:

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

input:

649557664 933437700

output:

2
11 649557653 

result:

ok Correct

Test #6:

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

input:

33396678 777360870

output:

2
1 33396677 

result:

ok Correct

Test #7:

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

input:

48205845 903124530

output:

3
23 48205823 -1 

result:

ok Correct

Test #8:

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

input:

251037078 505905400

output:

2
1 251037077 

result:

ok Correct

Test #9:

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

input:

30022920 172746860

output:

2
1 30022919 

result:

ok Correct

Test #10:

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

input:

63639298 808058790

output:

2
29 63639269 

result:

ok Correct

Test #11:

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

input:

76579017 362768406

output:

3
23 76578995 -1 

result:

ok Correct

Test #12:

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

input:

40423669 121437778

output:

3
3 40423667 -1 

result:

ok Correct

Test #13:

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

input:

449277309 720915195

output:

2
1 449277308 

result:

ok Correct

Test #14:

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

input:

81665969 919836918

output:

3
5 81665965 -1 

result:

ok Correct

Test #15:

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

input:

470578680 280387800

output:

2
1 470578679 

result:

ok Correct

Test #16:

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

input:

58450340 803305503

output:

2
1 58450339 

result:

ok Correct

Test #17:

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

input:

125896113 323676210

output:

3
17 125896097 -1 

result:

ok Correct

Test #18:

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

input:

381905348 434752500

output:

2
1 381905347 

result:

ok Correct

Test #19:

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

input:

78916498 653897673

output:

1
78916498 

result:

ok Correct

Test #20:

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

input:

35787885 270845190

output:

3
23 35787863 -1 

result:

ok Correct

Extra Test:

score: 0
Extra Test Passed