QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#852614 | #9738. Make It Divisible | ucup-team5234# | WA | 0ms | 3772kb | C++23 | 1.0kb | 2025-01-11 13:13:03 | 2025-01-11 13:13:04 |
Judging History
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;
}
Details
Tip: Click on the bar to expand more detailed information
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'