QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#858607 | #9738. Make It Divisible | 22016020736 | WA | 1ms | 5968kb | C++14 | 2.2kb | 2025-01-16 19:37:39 | 2025-01-16 19:37:49 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
using namespace std;
///int top;
int arr[20000009];
int brr[20000009];
signed main() {
int tt=0;
//if(3%(1==0) ) printf("aaaaa\n");
scanf("%lld",&tt);
int tmpt=tt;
int t=0;
while(tt--)
{
t++;
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);
brr[i]=x;
st.insert(x);
}
if(st.size()==1)
{
int ans=k,sum=k*(k+1)/2;
//if(tmpt==4&&t==2) printf("%lld",arr[3959599695969569]);
printf("%lld %lld\n",ans,sum);
continue;
}
if(tmpt==4&&t==2)
{
//printf("0 0\n");
//continue;
}
for(auto x:st)
{
arr[++top]=x;
}
int mx=arr[2],nx=arr[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)
{
if(i-nx>=1&&i-nx<=k)
xulie.insert(i-nx);
if(shu/i-nx>=1&&shu/i-nx<=k)
xulie.insert(shu/i-nx);
}
}
// xulie.insert(1);
int ans=0,sum=0;
sort(brr+1,brr+1+n);
for(auto x:xulie)
{
// printf("x:%lld\n",x);
bool f=true;
for(int j=2;j<=n;j++)
{
if( (brr[j]+x)%(brr[j-1]+x)!=0&&(brr[j-1]+x)%(brr[j]+x)!=0 ) f=false;
//if( (arr[j]+x)%(arr[1]+x)!=0) f=false;
}
if(tmpt==4&&t==2)
{
for(int j=1;j<=n;j++)
{
//printf("%lld ",brr[j]+x);
}
//return 0;
}
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: 0ms
memory: 5964kb
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: 0
Accepted
time: 0ms
memory: 5968kb
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 0 0 0 0 0 0
result:
ok 4 lines
Test #3:
score: -100
Wrong Answer
time: 1ms
memory: 5960kb
input:
500 4 1000000000 8 14 24 18 4 1000000000 17 10 18 14 4 1000000000 6 17 19 19 4 1000000000 15 14 15 25 4 1000000000 16 16 5 25 4 1000000000 4 30 20 5 4 1000000000 11 4 23 9 4 1000000000 14 25 13 2 4 1000000000 18 18 1 15 4 1000000000 22 22 22 28 4 1000000000 15 17 17 10 4 1000000000 22 14 13 25 4 100...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
wrong answer 178th lines differ - expected: '1 2', found: '0 0'