QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#856296 | #9738. Make It Divisible | 22016020736# | WA | 1ms | 3840kb | C++14 | 1.4kb | 2025-01-13 20:46:04 | 2025-01-13 20:46:06 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
using namespace std;
///int top;
int arr[20000009];
signed main() {
int tt=0;
scanf("%lld",&tt);
while(tt--)
{
int top=0;
set<int>st;
int n,k;
scanf("%lld%lld",&n,&k);
for(int i=1;i<=n;i++)
{
int x;
scanf("%lld",&x);
st.insert(x);
}
if(st.size()==1)
{
int ans=k,sum=k*(k+1)/2;
printf("%lld %lld\n",ans,sum);
continue;
}
for(auto x:st)
{
arr[++top]=x;
}
int mx=arr[top],nx=arr[top-1];
if(nx>=mx)
{
printf("0 0\n");
continue;
}
else
{
int shu=mx-nx;
set<int>xulie;
for(int i=1;i*i<=shu;i++)
{
if(shu%i==0)
{
xulie.insert(i+1);
xulie.insert(shu/i+1);
}
}
xulie.insert(1);
int ans=0,sum=0;
for(auto x:xulie)
{
bool f=true;
for(int j=1;j<top;j++)
{
if( (arr[top]+x)%(arr[j]+x)!=0) f=false;
}
if(f&&x<=k)
{
//printf("ans:%d\n",x);
sum+=x,ans++;
}
}
printf("%lld %lld\n",ans,sum);
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3840kb
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: 3840kb
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:
1 1 1 1 1 1 1 1
result:
wrong answer 1st lines differ - expected: '0 0', found: '1 1'