QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#834018#9738. Make It Divisibleremain11#WA 0ms3884kbC++20954b2024-12-27 10:03:512024-12-27 10:03:52

Judging History

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

  • [2024-12-27 10:03:52]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3884kb
  • [2024-12-27 10:03:51]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
using namespace std;
int B[50001];
int GCD(int X,int Y)
{
    if(!X||!Y)
    return X^Y;
    return GCD(Y,X%Y);
}
void Solve()
{
    ll N,K;
    scanf("%lld%lld",&N,&K);
    for(int i=1;i<=N;++i)
    {
        scanf("%d",&B[i]);
    }
    sort(B+1,B+N+1);
    if(B[1]==B[N])
    {
        printf("%lld %lld\n",K,(K+1)*K>>1);
        return;
    }
    int Gcd=0;
    for(int i=2;i<=N;++i)
    {
        Gcd=GCD(Gcd,B[i]-B[1]);
    }
    ll Ansa=0,Ansb=0;
    for(int i=1;i*i<=Gcd;++i)
    {
        if(Gcd%i)continue;
        if(i>B[1]&&i<=K)
        {
            ++Ansa;
            Ansb+=i-B[1];
        }
        if(i*i!=Gcd&&Gcd/i>B[1]&&Gcd/i<=K)
        {
            ++Ansa;
            Ansb+=Gcd/i-B[1];
        }
    }
    printf("%lld %lld\n",Ansa,Ansb);
}
int main()
{
    int T;
    scanf("%d",&T);
    while(T--)
    {
        Solve();
    }
}

详细

Test #1:

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

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

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'