QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#512199#9167. Coprime Arrayucup-team956#TL 928ms3696kbC++201.7kb2024-08-10 13:48:282024-08-10 13:48:28

Judging History

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

  • [2024-08-11 17:38:28]
  • hack成功,自动添加数据
  • (/hack/775)
  • [2024-08-10 13:48:28]
  • 评测
  • 测评结果:TL
  • 用时:928ms
  • 内存:3696kb
  • [2024-08-10 13:48:28]
  • 提交

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";
        return;
    }
    // cout << __gcd(-5, 10) << "!!!\n";
    for(int i = -1e7; i <= 1e7; i++) {
        if(__gcd(abs(i), s) == 1 && __gcd(abs(n - i), s) == 1 && abs(n - i) <= 1e9) {
            cout << 2 << "\n";
            cout << i << " " << n - i << "\n";
            return;
        }
    }
    // if(n != 9 || s != 6) while(1);
    for(int i = -1e3; i <= 1e3; i++) {
        for(int j = -1e3; j <= 1e3; j++) {
            if(__gcd(abs(i), s) == 1 && __gcd(abs(j), s) == 1 && __gcd(abs(n - i - j), s) == 1 && abs(n - i - j) <= 1e9) {
                cout << 3 << "\n";
                cout << i << " " << j << " " << n - i - j << "\n";
                return;
            }
        }
    }
    for(int i = -1e2; i <= 1e2; i++) {
        for(int j = -1e2; j <= 1e2; j++) {
            for(int k = -1e2; k <= 1e2; k++) {
                if(__gcd(i, s) == 1 && __gcd(j, s) == 1 && __gcd(k, s) == 1 && __gcd(n - i - j - k, s) == 1) {
                    cout << 4 << "\n";
                    cout << i << " " << j << " " << k << " " << n - i - j - k << "\n";
                    return;
                }
            }
        }
    }
}

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;
}

詳細信息

Test #1:

score: 100
Accepted
time: 173ms
memory: 3696kb

input:

9 6

output:

3
-997 -997 2003

result:

ok Correct

Test #2:

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

input:

14 34

output:

2
-9999999 10000013

result:

ok Correct

Test #3:

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

input:

1000000000 223092870

output:

2
29 999999971

result:

ok Correct

Test #4:

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

input:

2 1000000000

output:

2
-9999999 10000001

result:

ok Correct

Test #5:

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

input:

649557664 933437700

output:

2
-9999997 659557661

result:

ok Correct

Test #6:

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

input:

33396678 777360870

output:

2
-9999991 43396669

result:

ok Correct

Test #7:

score: -100
Time Limit Exceeded

input:

48205845 903124530

output:


result: