QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#747896 | #9738. Make It Divisible | SSAABBEERR | WA | 1ms | 3660kb | C++20 | 1.3kb | 2024-11-14 18:39:13 | 2024-11-14 18:39:13 |
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];
if(n == 1)
{
cout << m << " " << m * (1 + m) / 2 << endl;
return;
}
int w = 0, ma = 1e18;
rep(i, 1, n) ma = min(ma, a[i]);
rep(i, 1, n - 1)
{
int x = a[i], y = a[i + 1];
if(x == y) continue;
if(x > y) swap(x, y);
if(!w) w = y - x;
else w = __gcd(w, y - x);
}
if(!ma)
{
cout << m << " " << m * (1 + m) / 2 << endl;
return;
}
int sum = 0, ans = 0;
rep(i, 1, sqrt(w))
{
if(w % i != 0) continue;
if(i > ma && i - ma <= m) sum ++ , ans += i - ma;
if((w / i) != i)
{
if(w / i > ma && w / i - ma <= m) sum ++ , ans += (w / i - ma);
}
}
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: 1ms
memory: 3644kb
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: 3660kb
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'