QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#757942 | #9738. Make It Divisible | ruoye123456# | WA | 0ms | 3592kb | C++20 | 1.8kb | 2024-11-17 14:47:30 | 2024-11-17 14:47:30 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define x first
#define y second
typedef pair<int,int> PII;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef vector<string> VS;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
vector<int> vx;
inline void divide() {sort(vx.begin(),vx.end());vx.erase(unique(vx.begin(),vx.end()),vx.end());}
inline int mp(int x) {return upper_bound(vx.begin(),vx.end(),x)-vx.begin();}
inline int log_2(int x) {return 31-__builtin_clz(x);}
inline int popcount(int x) {return __builtin_popcount(x);}
inline int lowbit(int x) {return x&-x;}
inline ll Lsqrt(ll x) { ll L = 1,R = 2e9;while(L + 1 < R){ll M = (L+R)/2;if(M*M <= x) L = M;else R = M;}return L;}
const int N = 50005;
ll n,k;
void solve()
{
cin>>n>>k;
vector<ll> arr(n);
bool is=false;
for(int i=0;i<n;i++)
{
cin>>arr[i];
if(i>=1&&arr[i]!=arr[i-1]) is=true;
}
if(!is)
{
cout<<k<<' '<<(k+1)*k/2<<'\n';
return ;
}
sort(arr.begin(),arr.end());
ll G=0;
for(int i=1;i<n;i++)
{
G=gcd(G,arr[i]-arr[i-1]);
}
//cout<<G<<' ';
ll sum=0,cnt=0;
for(int i=1;i<G/i;i++)
{
if(G%i) continue;
if(i>arr[0]&&k>=i)
{sum+=(i-arr[0]);
cnt++;
}
if(G/i!=i&&G/i>arr[0]&&k>=G/i)
{
sum+=(G/i-arr[0]);
cnt++;
}
}
cout<<cnt<<' '<<sum<<'\n';
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int T = 1;
//cin>>T;
// for(int i=1;i<N;++i)
// {
// for(int j=i;j<N;j+=i)
// {
// ++cnt[j];//约数个数
// sum[j]+=i;//约数个数和
// }
// }
cin>>T;
while(T--)
{
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3584kb
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: 3592kb
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'