QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#746138#9738. Make It Divisiblethe_fool#WA 0ms3492kbC++201.0kb2024-11-14 13:33:372024-11-14 13:33:37

Judging History

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

  • [2024-11-27 18:44:44]
  • hack成功,自动添加数据
  • (/hack/1263)
  • [2024-11-14 13:33:37]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3492kb
  • [2024-11-14 13:33:37]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long
using namespace std;

using LL = long long;

void solve() {
    int n,k;
    cin>>n>>k;
    vector<int> a(n);
    for(int i=0;i<n;i++) {
        cin>>a[i];
    }
    sort(a.begin(),a.end());
    int g = 0;
    for(int i=1;i<n;i++) {
        g = __gcd(g, a[i] - a[0]);
    }
    if(g == 0) {
        cout<<k<<' '<<k*(k+1)/2<<endl;
        return ;
    }
    // cerr<<g<<endl;
    int cnt = 0;
    int sum = 0;
    for(int i=1;i*i<=g;i++) {
        if(g%i == 0) {
            if(i > a[0] && i-a[0] <= k) {
                cnt++;
                sum += i-a[0];
                //cerr<<i<<' ';
            }
            if(g/i!=i&&g/i>a[0] && g/i-a[0]<=k) {
                cnt++;
                sum += g/i-a[0];
                // cerr<<g/i<<' ';
            }
        }
    }
    cout<<cnt<<' '<<sum<<endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    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: 3476kb

input:

3
5 10
7 79 1 7 1
2 1000000000
1 2
1 100
1000000000

output:

3 8
0 0
100 5050

result:

ok 3 lines

Test #2:

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

input:

4
201 1000000000
1 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5...

output:

0 0
1 1
0 0
0 0

result:

wrong answer 2nd lines differ - expected: '0 0', found: '1 1'