QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#857444#9738. Make It DivisibleWzy#WA 1ms3712kbC++141.3kb2025-01-15 18:19:202025-01-15 18:19:20

Judging History

你现在查看的是最新测评结果

  • [2025-01-15 18:19:20]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3712kb
  • [2025-01-15 18:19:20]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> 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;


int gcd(int a,int b){
    return b?gcd(b,a%b):a;
}


void solve(){
    int n,k;
    cin>>n>>k;


    vector<int> a(n);


    for(int i=0;i<n;i++) cin>>a[i];

    if(n==1){
        LL res=(k)*(k+1)/2;
        cout<<k<<" "<<res<<endl;

        return;
    }

    sort(a.begin(),a.end());

    a.erase(unique(a.begin(),a.end()),a.end());

    vector<int> b;


    for(int i=1;i<a.size();i++) b.push_back(a[i]-a[i-1]);


    
    int t=b[0];
    LL res=0,num=0;
    for(int i=1;i<b.size();i++){
        t=gcd(b[i],t);
    }

    vector<LL> ans;
    for(int i=2;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-a[0]>k) continue;
        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'