QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#739793 | #9738. Make It Divisible | HUY1# | WA | 0ms | 3572kb | C++20 | 1.2kb | 2024-11-12 23:07:58 | 2024-11-12 23:08:04 |
Judging History
你现在查看的是最新测评结果
- [2024-11-27 18:44:44]
- hack成功,自动添加数据
- (/hack/1263)
- [2024-11-14 09:10:13]
- hack成功,自动添加数据
- (/hack/1178)
- [2024-11-12 23:07:58]
- 提交
answer
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
#define endl '\n'
#define MAXN 50005
ll a[MAXN],b[MAXN];
void solve()
{
ll n, k;
cin >> n >> k;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
sort(a + 1, a + n + 1);
n = unique(a + 1, a + n + 1) - a - 1;
if (n == 1) {
cout << k << " " << k * (k + 1) / 2 << endl;
return;
}
ll x = a[n];
map<ll, ll> mp, st;
for (int i = 1; i <= n - 1; i++) {
ll y = a[i];
ll t = x - y;
if (i == 1) {
for (int j = 1; j <= t / j; j++) {
if (t % j == 0) {
if (j > y) {
mp[j - y] = 1;
}
if (t / j != j) {
if (t / j > y) {
mp[t / j - y] = 1;
}
}
}
}
} else {
for (auto k : mp) {
if ((x + k.first) % (k.first + y) != 0) {
mp[k.first] = 0;
}
}
}
}
ll res = 0, cnt = 0;
for (auto k : mp) {
if (k.second != 0) {
res += k.first;
cnt++;
}
}
cout << cnt << ' ' << res << endl;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t = 1;
cin >> t;
while (t--) {
solve();
}
return 0;
}
/*
3
5 10
7 79 1 7 1
2 1000000000
1 2
1 100
1000000000
*/
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3572kb
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: 3548kb
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:
1 1 1 1 1 1 1 1
result:
wrong answer 1st lines differ - expected: '0 0', found: '1 1'