QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#852614#9738. Make It Divisibleucup-team5234#WA 0ms3772kbC++231.0kb2025-01-11 13:13:032025-01-11 13:13:04

Judging History

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

  • [2025-01-11 13:13:04]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3772kb
  • [2025-01-11 13:13:03]
  • 提交

answer

#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define pb(a) push_back(a)
#define all(a) a.begin(), a.end()
vector<ll> divisor(ll n) {
    vector<ll> v;
    for(ll i = 1; i * i <= n; i ++) {
        if(n % i == 0) {
            if(i * i != n) v.pb(n/i);
            v.pb(i);
        }
    }
    return v;
}

void solve() {
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i, n) {
        cin >> a[i];
    }
    auto b = a;
    sort(all(b));
    ll g = 0;
    rep(i, n - 1) g = __gcd(g, b[i + 1] - b[i]);
    if(g == 0) {
        cout << k << " " << (k + 1) * k / 2 << endl;
        return ;
    }
    ll Min = b[0];
    auto vec = divisor(g);
    ll cnt = 0, ans = 0;
    for(ll e : vec) {
        if(e > Min) {
            if(e - Min > k) continue;
            ans += e - Min;
            cnt ++;
        }
    }
    cout << cnt << " " << ans << endl;
    
}
int main(){
    int t; cin >> t;
    rep(i, t) solve();
    return 0;
}

详细

Test #1:

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

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

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'