QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#786157#9738. Make It Divisiblexyggzsf#WA 1ms3832kbC++141.4kb2024-11-26 20:29:052024-11-26 20:29:07

Judging History

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

  • [2024-11-27 18:44:44]
  • hack成功,自动添加数据
  • (/hack/1263)
  • [2024-11-26 20:29:07]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3832kb
  • [2024-11-26 20:29:05]
  • 提交

answer

#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
#define int    long long 
typedef pair<int, int>pii;
typedef pair<char, int>pci;
typedef pair<int, pii>piii;
const int mod = 998244353;
const int N = 5e5 + 100;

int n, k;
int a[N];

int gcd(int a, int b) {
    return b == 0 ? a : gcd(b, a % b);
}

void solve()
{
    cin >> n >> k;
    map<int, int> mp;
    for (int i = 1; i <= n; i++) {
        int t;
        cin >> t;
        mp[t] = t;
    }

    n = mp.size();
    int temp = 1;
    for (auto t : mp) {
        a[temp++] = t.first;
    }

    if (n == 1) {
        cout << k << ' ' << ((k + 1) * k) / 2 << endl;
        return;
    }

    temp = a[2] - a[1];
    for (int i = 2; i <= n; i++) temp = gcd(temp, a[i] - a[i - 1]);

    vector<int> v;
    for (int i = 1; i * i <= temp; i++) {
        if (temp % i == 0) {
            v.push_back(i);
            if(i!=temp/i) v.push_back(temp / i);
        }
    }

    int ans = 0, ans_sum = 0;

    for (auto t : v) {
        //cout << t<<' ';
        if (t - a[1] > k) continue;
        if (t <= a[1]) continue;
        int yu = a[1] % t;
        ans++;
        ans_sum += t - a[1];
        //cout << t << endl;
    }

    cout << ans << ' ' << ans_sum << endl;

}

signed main()
{
    ios::sync_with_stdio(0); cout.tie(0); cin.tie(0);
    int t = 1;
    cin >> t;
    while (t--) {
        solve();
    }
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3532kb

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

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'