QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#789322#9738. Make It DivisibleshinonomezhouWA 0ms3632kbC++171.0kb2024-11-27 19:53:452024-11-27 19:53:46

Judging History

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

  • [2024-11-27 19:53:46]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3632kb
  • [2024-11-27 19:53:45]
  • 提交

answer

//
// Created by 10842 on 24-11-27.
//
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int M=3e5+7;
const ll inf=0x3f3f3f3f3f3f;

set<ll>s;

void prime(ll n)
{
    for(ll i=1;i*i<=n;i++)
    {
        if(n%i==0)
        {
            s.insert(i);
            if(n/i!=i)
            {
                s.insert(n/i);
            }
        }
    }
}

void solve()
{
    s.clear();
    ll i,j,k,x=0,sum=0,m=inf,n,p,g=0;
    cin>>n>>k;
    ll a[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        m=min(m,a[i]);
    }
    sort(a,a+n);
    for(i=n-1;i>0;i--)
    {
        g=__gcd(g,a[i]-a[i-1]);
    }
    if(!g)
    {
        cout<<k<<" "<<(k+1)*k/2<<"\n";
        return;
    }
    prime(g);
    for(auto e:s)
    {
        if(e>m&&e<=k)
        {
            x++;
            sum+=e-m;
        }
    }
    cout<<x<<" "<<sum<<"\n";
}

int main()
{
    ios::sync_with_stdio(false);
//    cin.tie(0);
    ll t;
    cin>>t;
    while(t--)
    {
        solve();
    }
}

詳細信息

Test #1:

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

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

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'