QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#741780#9738. Make It DivisibleH_ZzZ#WA 0ms3556kbC++231.0kb2024-11-13 15:13:042024-11-13 15:13:07

Judging History

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

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

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
int __ = 1,n;
const int N = 1e5 + 5;

int b[N];
int mn,k;
bool check(int x)
{
    return x > mn && x - mn <= k;
}
void solve(){
    int n;
    cin >> n >> k;
    mn = 1e9;
    for(int i = 1; i <= n; i++) cin >> b[i], mn = min(mn,b[i]);
    if(n == 1)
    {
        cout << k << ' ' << (1 + k) * k / 2 << endl;
        return;
    }
    int g = 0;
    for(int i = 1; i <= n; i++) g = gcd(g,b[i] - mn);
    if(g == 0)
    {
        cout << k << ' ' << (1 + k) * k / 2 << endl;
        return;
    }
    int cnt = 0, sum = 0;
    for(int i = 1; i <= g / i; i++)
        if(g % i == 0)
        {
            if(check(i)) cnt ++, sum += i - mn;
            if(i * i != g && check(g/i)) cnt ++, sum += g / i - mn;
        }
    cout << cnt << ' ' << sum << endl;
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);cout.tie(nullptr);
    cin >> __;
    while (__--){
        solve();
    }
    return 0;
}

詳細信息

Test #1:

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

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'