QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#795319 | #9738. Make It Divisible | Nlll# | WA | 0ms | 3612kb | C++20 | 935b | 2024-11-30 19:34:21 | 2024-11-30 19:34:22 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,j,k) for(int i=j;i<=k;++i)
#define For(i,j,k) for(int i=j;i>-k;--i)
const int N = 5e4+111;
int a[N],b[N];
int gcd(int x,int y){
if(!x) return y;
if(!y) return x;
return gcd(y,x%y);
}
int p[N];
int c[N];
void sol(){
int n,k;
cin>>n>>k;
FOR(i,1,n) cin>>a[i];
sort(a+1,a+1+n);
FOR(i,1,n) b[i] = a[i]-a[1];
int d = 0;
FOR(i,1,n) d = gcd(d,b[i]);
int up = sqrt(d);
int num = 0;
if(d==0){
cout<<k<<' '<<1ll*k*(k+1)/2;
return;
}
long long sum = 0;
long long tot = 0;
FOR(i,1,up){
if(d%i==0){
if(i>a[1]&&(i-a[1])<=k){
sum += i-a[1];
++tot;
}
}
if(d!=i*i){
if(d/i>a[1]&&(d/i-a[1])<=k){
sum += d/i-a[1];
++tot;
}
}
}
cout<<tot<<' '<<sum<<'\n';
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t;
cin>>t;
while(t--){
sol();
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3612kb
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: 3552kb
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'