QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#741757 | #9738. Make It Divisible | H_ZzZ# | WA | 0ms | 3576kb | C++23 | 933b | 2024-11-13 15:10:16 | 2024-11-13 15:10:16 |
Judging History
你现在查看的是最新测评结果
- [2024-11-27 18:44:44]
- hack成功,自动添加数据
- (/hack/1263)
- [2024-11-14 09:10:13]
- hack成功,自动添加数据
- (/hack/1178)
- [2024-11-13 15:10:16]
- 提交
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);
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: 3544kb
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: 3576kb
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'