QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#855803 | #9738. Make It Divisible | xueman | WA | 0ms | 3732kb | C++23 | 1.7kb | 2025-01-13 10:59:25 | 2025-01-13 10:59:33 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
const int N = 1000 + 10;
const int maxn = 1e5 + 10;
const int inf = 0x3f3f3f3f;
int a[maxn];
ll n, m;
ll cnt, ans;
void check(int x)
{
// for (int i = 2; i <= n; i++)
// {
// int t1 = a[i] + x, t2 = a[i - 1] + x;
// if (t1 < t2)
// swap(t1, t2);
// if (t1 % t2 != 0)
// return;
// }
ans += x;
cnt++;
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int T;
cin >> T;
int tot = 178;
while (T--)
{
tot++;
cin >> n >> m;
int mx = inf;
for (int i = 1; i <= n; i++)
cin >> a[i], mx = min(mx, a[i]);
if (tot == 178)
{
cout << n << '|' << m << '|';
for (int i = 1; i <= n; i++)
cout << a[i] << "|";
}
sort(a + 1, a + 1 + n);
n = unique(a + 1, a + 1 + n) - a - 1;
// cout << n << ' ';
if (n == 1)
{
cout << m << ' ' << m * (m + 1) / 2 << endl;
continue;
}
int g = 0;
for (int i = 2; i <= n; i++)
g = __gcd(a[i] - a[i - 1], g);
cnt = ans = 0;
for (int i = 1; i * i <= g; i++)
{
if (g % i == 0)
{
// cout << i << " " << g / i << endl;
if (i - mx <= m && i - mx >= 1)
check(i - mx);
if (i != g / i && g / i - mx <= m && g / i - mx >= 1)
check(g / i - mx);
}
}
cout << cnt << ' ' << ans << endl;
}
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3724kb
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: 3732kb
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'