QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#867004 | #9738. Make It Divisible | sqrteipi | WA | 1ms | 3712kb | C++20 | 1.2kb | 2025-01-22 23:59:12 | 2025-01-22 23:59:13 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
int factor[10000];
int t;
cin >> t;
for (int j=0; j<t; j++){
int n,k;
cin >> n >> k;
int q=1000000000;
int arr[n];
for (int i=0; i<n; i++){
cin >> arr[i];
q=min(q,arr[i]);
}
int g=0;
for (int i=0; i<n; i++){
if (arr[i]-q!=0){
if (g==0){
g=arr[i]-q;
}else{
g=gcd(arr[i]-q,g);
}
}
}
set<int> s;
if (g==0){
cout << k << " " << k*(k+1)/2 << endl;
}else{
s.insert(1);
int pt=0;
for (int i=2; i<=sqrt(g); i++){
if (g%i==0){
for (int p : s){
factor[pt]=p, pt++;
}
for (int t=0; t<pt; t++){
s.insert(factor[t]*i);
}
g/=i, pt=0;
}
}
for (int p : s){
factor[pt]=p, pt++;
}
for (int t=0; t<pt; t++){
s.insert(factor[t]*g);
}
int ans=0, num=0;
for (int p : s){
if (q<p && p-q<=k){
num++, ans+=p-q;
}
}
cout << num << " " << ans << endl;
}
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3712kb
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: 3712kb
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'