QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#855961#9738. Make It Divisibleshi2uku#WA 0ms3732kbC++141.2kb2025-01-13 13:51:062025-01-13 13:51:06

Judging History

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

  • [2025-01-13 13:51:06]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3732kb
  • [2025-01-13 13:51:06]
  • 提交

answer

#include <algorithm>
#include <iostream>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
using pii = pair<ll, ll>;
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 l = a[0] + 1, r = a[0] + k;
    for (int i = 0; i < n; ++i) a[i] -= l - 1;
    int d = 0;
    for (int i = 0; i < n; ++i) d = __gcd(d, a[i]);
    if (d == 0) {
        int num = r - l + 1;
        ll sum = 1ll * num * (r + l) / 2;
        cout << num << " " << sum - 1ll * (l - 1) * num << '\n';
        return;
    }
    set<int> s;
    auto valid = [&](int x) -> bool {
        return x >= l && x <= r;
    };
    for (int i = 1; i * i <= d; ++i) {
        if (d % i == 0) {
            if (valid(i)) s.insert(i);
            if (valid(d / i)) s.insert(d / i);
        }
    }
    ll sum = 0;
    for (auto u : s) sum += u;
    int num = s.size();
    cout << num << " " << sum - 1ll * (l - 1) * num << '\n';
}
int main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(0);
    int t;
    cin >> t;
    while (t--) solve();
}
/*
3
5 10
7 79 1 7 1
2 1000000000
1 2
1 100
1000000000
*/

详细

Test #1:

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

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

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'