QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#834018 | #9738. Make It Divisible | remain11# | WA | 0ms | 3884kb | C++20 | 954b | 2024-12-27 10:03:51 | 2024-12-27 10:03:52 |
Judging History
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();
}
}
Details
Tip: Click on the bar to expand more detailed information
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'