QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#857498 | #9738. Make It Divisible | Wzy# | WA | 1ms | 3712kb | C++14 | 1.8kb | 2025-01-15 19:14:19 | 2025-01-15 19:14:23 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> PII;
const int N=5e5+10,M=2*N;
//const int mod=998244353;
const LL mod=1e9+7;
const LL INF=1e18+7;
//LL h[N],e[M],ne[M],idx;
int T=1;
LL gcd(LL a,LL b){
return b?gcd(b,a%b):a;
}
/*PII dp(vector<LL> a,LL k){
LL res=0,num=0;
for(int i=1;i<=k;i++){
for(int j=0;j<a.size();j++) a[j]++;
bool sg=true;
for(int j=1;j<a.size();j++) if(a[j]%a[0]) sg=false;
if(sg) res+=i,num++;
}
return {num,res};
}*/
void solve(){
LL n,k;
cin>>n>>k;
vector<LL> a;
for(int i=0;i<n;i++){
int x;
cin>>x;
a.push_back(x);
}
sort(a.begin(),a.end());
//PII q=dp(a,k);
//cout<<q.first<<" "<<q.second<<endl;
a.erase(unique(a.begin(),a.end()),a.end());
vector<LL> b;
for(int i=1;i<a.size();i++) b.push_back(a[i]-a[i-1]);
if(a.size()==1){
LL res=(LL)(k)*(k+1)/2;
cout<<k<<" "<<res<<endl;
return;
}
LL t=b[0];
LL res=0,num=0;
for(int i=1;i<b.size();i++){
t=gcd(b[i],t);
}
if(t==1){
cout<<0<<" "<<0<<endl;
return;
}
vector<LL> ans;
for(LL i=1;i*i<=t;i++){
if(t%i) continue;
ans.push_back(i);
if(i*i!=t) ans.push_back(t/i);
}
//ans.push_back(t);
for(auto g:ans){
//cout<<g<<endl;
if(a[0]>=g) continue;
if(g>k+a[0]) continue;
//cout<<g-a[0]<<endl;
res+=g-a[0],num++;
}
cout<<num<<" "<<res<<endl;
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>T;
while(T--) solve();
return 0;
}
詳細信息
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'