QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#739556 | #9738. Make It Divisible | HUY1# | WA | 0ms | 3628kb | C++20 | 1.2kb | 2024-11-12 22:10:08 | 2024-11-12 22:10:09 |
Judging History
你现在查看的是最新测评结果
- [2024-11-27 18:44:44]
- hack成功,自动添加数据
- (/hack/1263)
- [2024-11-14 09:10:13]
- hack成功,自动添加数据
- (/hack/1178)
- [2024-11-12 22:10:08]
- 提交
answer
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
#define endl '\n'
#define MAXN 50005
ll a[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, bool> mp, st;
for (int i = n - 1; i >= 1; i--) {
ll y = a[i];
ll t = x - y;
if (i == n - 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 {
st = mp;
for (auto k : mp) {
if (t % (k.first + y) != 0) {
st.erase(k.first);
}
}
mp = st;
}
}
ll res = 0;
for (auto k : mp) {
res += k.first;
}
cout << mp.size() << ' ' << 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
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3628kb
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: 3624kb
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'