QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#746138 | #9738. Make It Divisible | the_fool# | WA | 0ms | 3492kb | C++20 | 1.0kb | 2024-11-14 13:33:37 | 2024-11-14 13:33:37 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
using namespace std;
using LL = long long;
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 g = 0;
for(int i=1;i<n;i++) {
g = __gcd(g, a[i] - a[0]);
}
if(g == 0) {
cout<<k<<' '<<k*(k+1)/2<<endl;
return ;
}
// cerr<<g<<endl;
int cnt = 0;
int sum = 0;
for(int i=1;i*i<=g;i++) {
if(g%i == 0) {
if(i > a[0] && i-a[0] <= k) {
cnt++;
sum += i-a[0];
//cerr<<i<<' ';
}
if(g/i!=i&&g/i>a[0] && g/i-a[0]<=k) {
cnt++;
sum += g/i-a[0];
// cerr<<g/i<<' ';
}
}
}
cout<<cnt<<' '<<sum<<endl;
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1;
cin >> t;
while (t--) {
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3476kb
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: 3492kb
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'