QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#836140 | #9738. Make It Divisible | Pinkychow | WA | 1ms | 3796kb | C++14 | 1.2kb | 2024-12-28 16:52:32 | 2024-12-28 16:52:33 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
void solve() {
int n, k;
cin >> n >> k;
vector<int> a(n);
set<int> s;
for (auto &i : a) {
std::cin >> i;
s.insert(i);
}
if (s.size() == 1) {
std::cout << k << " " << k * (k + 1) / 2 << "\n";
return ;
}
int x, y;
for (int i = 0; i < n - 1; i ++) if (a[i] != a[i + 1]) {
x = a[i];
y = a[i + 1];
break;
}
if (x > y) std::swap(x, y);
int d = y - x;
auto check = [&](int add) {
if (add > k || add <= 0) return false;
auto b = a;
for (auto &i : b) i += add;
for (int i = 1; i < n; i ++) if (std::max(b[i], b[i - 1]) % std::min(b[i], b[i - 1])) return false;
return true;
};
int cnt = 0, sum = 0;
for (int i = 1; i * i <= d; i ++) if (d % i == 0) {
if (check(i - x)) cnt ++, sum += i - x;
if (i * i != d && check(d / i - x)) cnt ++, sum += d / i - x;
}
std::cout << cnt << " " << sum << "\n";
}
signed main(){
int t;
cin>>t;
while(t--){
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3604kb
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: 1ms
memory: 3796kb
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'