QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#745421 | #9738. Make It Divisible | vision# | WA | 0ms | 3776kb | C++20 | 1.2kb | 2024-11-14 09:49:49 | 2024-11-14 09:49:54 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
#define lson k<<1
#define rson (k<<1)|1
#define debug cout<<666<<endl;
using namespace std;
const int N=1e6+5;
int a[N];
void vision()
{
int n,k;
cin>>n>>k;
int g=0;
int mi=1e9+1;
for(int i=1;i<=n;i++)
{
int x;
cin>>a[i];
mi=min(a[i],mi);
}
for(int i=1;i<=n;i++)
{
g=__gcd(g,a[i]-mi);
}
if(g==0)
{
cout<<k<<" "<<k*(k+1)/2<<"\n";
return;
}
vector<int>a;
a.push_back(0);
for(int i=1;i*i<=g;i++)
{
if(g%i==0)
{
a.push_back(i);
if(g/i!=i)a.push_back(g/i);
}
}
sort(a.begin(),a.end());
int al=mi+1;
int ar=mi+k;
int l=lower_bound(a.begin(),a.end(),al)-a.begin();
int r=upper_bound(a.begin(),a.end(),ar)-a.begin();
r--;
int sum=0;
int ans=r-l+1;
for(int i=l;i<=r;i++)
{
sum+=a[i]-mi;
}
cout<<ans<<" "<<sum<<"\n";
return ;
}
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int t=1;
cin>>t;
while(t--){
vision();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3776kb
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: 3480kb
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'