QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#791732#9738. Make It DivisibleEqvpkbzWA 0ms3768kbC++231.2kb2024-11-28 20:36:262024-11-28 20:36:27

Judging History

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

  • [2024-11-28 20:36:27]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3768kb
  • [2024-11-28 20:36:26]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const ll N = 3e5 + 5;
const ll P = 998244353;
ll n, m, k;

void solve() {
    cin >> n >> k;
    vector<int> b(n + 2);
    for (int i = 1; i <= n; i++) {
        cin >> b[i];
    }
    sort(b.begin() + 1, b.begin() + 1 + n);
    int now = 0;
    for (int i = 2; i <= n; i++) {
        now = __gcd(b[i] - b[1], now);
    }
    if (now == 0) {
        cout << k << ' ' << (k + 1) * (k) / 2 << '\n';
        return;
    }
    // cout << now << ' ';
    ll sum = 0, ans = 0;
    for (ll i = 1; i * i <= now; i++) {
        if (now % i == 0) {
            if (i > b[1] && i - b[1] <= k) {
                // cout << i << ' ';
                sum++;
                ans += i - b[1];
            }
            if ((now / i) > b[1] && (now / i) != i && (now / i) - b[1] <= k) {
                // cout << i << ' ';
                sum++;
                ans += (now / i) - b[1];
            }
        }
    }
    cout << sum << ' ' << ans << '\n';
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int _ = 1;
    cin >> _;
    while (_--) {
        solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

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'