QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#745421#9738. Make It Divisiblevision#WA 0ms3776kbC++201.2kb2024-11-14 09:49:492024-11-14 09:49:54

Judging History

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

  • [2024-11-27 18:44:44]
  • hack成功,自动添加数据
  • (/hack/1263)
  • [2024-11-14 09:49:54]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3776kb
  • [2024-11-14 09:49:49]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long
#define lson k<<1
#define rson (k<<1)|1
#define debug cout<<666<<endl;
using namespace std;
const int N=1e6+5;
int a[N];
void vision()
{
    int n,k;
    cin>>n>>k;
    int g=0;
    int mi=1e9+1;
    for(int i=1;i<=n;i++)
    {
        int x;
        cin>>a[i];
        mi=min(a[i],mi);
    }
    for(int i=1;i<=n;i++)
    {
        g=__gcd(g,a[i]-mi);
    }
    if(g==0)
    {
        cout<<k<<" "<<k*(k+1)/2<<"\n";
        return;
    }
    vector<int>a;
    a.push_back(0);
    for(int i=1;i*i<=g;i++)
    {
        if(g%i==0)
        {
            a.push_back(i);
            if(g/i!=i)a.push_back(g/i);
        }
    }
    sort(a.begin(),a.end());
    int al=mi+1;
    int ar=mi+k;
    int l=lower_bound(a.begin(),a.end(),al)-a.begin();
    int r=upper_bound(a.begin(),a.end(),ar)-a.begin();
    r--;
    int sum=0;
    int ans=r-l+1;
    for(int i=l;i<=r;i++)
    {
        sum+=a[i]-mi;
    }
    cout<<ans<<" "<<sum<<"\n";
    return ;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int t=1;
    cin>>t;
    while(t--){
        vision();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3776kb

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: 3480kb

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'