QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#789322 | #9738. Make It Divisible | shinonomezhou | WA | 0ms | 3632kb | C++17 | 1.0kb | 2024-11-27 19:53:45 | 2024-11-27 19:53:46 |
Judging History
answer
//
// Created by 10842 on 24-11-27.
//
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int M=3e5+7;
const ll inf=0x3f3f3f3f3f3f;
set<ll>s;
void prime(ll n)
{
for(ll i=1;i*i<=n;i++)
{
if(n%i==0)
{
s.insert(i);
if(n/i!=i)
{
s.insert(n/i);
}
}
}
}
void solve()
{
s.clear();
ll i,j,k,x=0,sum=0,m=inf,n,p,g=0;
cin>>n>>k;
ll a[n];
for(i=0;i<n;i++)
{
cin>>a[i];
m=min(m,a[i]);
}
sort(a,a+n);
for(i=n-1;i>0;i--)
{
g=__gcd(g,a[i]-a[i-1]);
}
if(!g)
{
cout<<k<<" "<<(k+1)*k/2<<"\n";
return;
}
prime(g);
for(auto e:s)
{
if(e>m&&e<=k)
{
x++;
sum+=e-m;
}
}
cout<<x<<" "<<sum<<"\n";
}
int main()
{
ios::sync_with_stdio(false);
// cin.tie(0);
ll t;
cin>>t;
while(t--)
{
solve();
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3588kb
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: 3632kb
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'