QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#747699 | #9738. Make It Divisible | SSAABBEERR | WA | 0ms | 3632kb | C++20 | 1.1kb | 2024-11-14 17:56:02 | 2024-11-14 17:56:02 |
Judging History
answer
#include<bits/stdc++.h>
#define endl '\n'
#define int long long
#define rep(i, a, b) for(int i = a; i <= b; i ++ )
#define pre(i, a, b) for(int i = a; i >= b; i -- )
using namespace std;
const int N = 1e6 + 10;
int n, m, k;
int a[N];
void solve()
{
cin >> n >> m;
rep(i, 1, n) cin >> a[i];
sort(a + 1, a + n + 1);
if(a[1] == a[n])
{
cout << m << " " << m * (1 + m) / 2 << endl;
return;
}
rep(i, 2, n) a[i] -= a[1];
int w = 0;
rep(i, 2, n)
{
if(!a[i]) continue;
else if(!w) w = a[i];
else w = __gcd(w, a[i]);
}
int sum = 0, ans = 0;
rep(i, 1, sqrt(w))
{
if(w % i != 0) continue;
if(i > a[1] && i - a[1] <= m) sum ++ , ans += i - a[1];
if(w / i != i)
{
if(w / i > a[1] && w / i - a[1] <= m) sum ++ , ans += (w / i - a[1]);
}
}
cout << sum << " " << ans << endl;
}
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int _;
_ = 1;
cin >> _;
while(_ -- )
{
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3632kb
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: 3524kb
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'