QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#744067 | #9738. Make It Divisible | ucup-team4975# | WA | 11ms | 3820kb | C++14 | 2.3kb | 2024-11-13 20:44:54 | 2024-11-13 20:44:54 |
Judging History
你现在查看的是最新测评结果
- [2024-11-27 18:44:44]
- hack成功,自动添加数据
- (/hack/1263)
- [2024-11-14 09:10:13]
- hack成功,自动添加数据
- (/hack/1178)
- [2024-11-13 20:44:54]
- 提交
answer
#define LOCAL
#include <bits/stdc++.h>
#define fir first
#define sec second
#define el '\n'
#ifdef LOCAL
#define FINISH cerr << "FINISH" << endl;
#else
#define FINISH ;
#endif
#ifdef LOCAL
#define debug(x) cerr << setw(4) << #x << " == " << x << endl
#else
#define debug(x)
#endif
#ifdef LOCAL
#define debugv(x) \
cerr << setw(4) << #x << ":: "; \
for (auto i : x) \
cerr << i << " "; \
cerr << endl
#else
#define debugv(x)
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
ostream& operator<<(ostream& out, PII& x)
{
out << x.fir << " " << x.sec << endl;
return out;
}
const int mod = 998244353;
const int inf = 0x3f3f3f3f;
const int N = 200020;
void solve()
{
int n, k;
cin >> n >> k;
vector<int> a(n + 1, 0);
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
if (n == 1) {
cout << k << " " << 1ll * (k + 1) * k / 2 << el;
return;
}
unordered_map<int, int> ans;
int nowans = 0;
auto merge = [&](auto& self, int l, int r) {
if (l >= r)
return;
int mn = inf;
for (int i = l; i <= r; i++) {
mn = min(mn, a[i]);
}
// cout << l << " " << r << " " << mn << endl;
int g = 0;
for (int i = l + 1; i <= r; i++) {
int res = abs(a[i] - a[i - 1]);
g = __gcd(g, res);
}
if (g == 0)
return;
if (l == 1 && r == n) {
for (int i = 1; i * i <= g; i++) {
if (g % i == 0) {
if (i > mn)
ans[i - mn] = 1;
if (g / i > mn)
ans[g / i - mn] = 1;
}
}
nowans = 1;
}
else {
for (int i = 1; i * i <= g; i++) {
if (i * i == g) {
if (i > mn)
ans[i - mn]++;
}
else if (g % i == 0) {
if (i > mn)
ans[i - mn]++;
if (g / i > mn)
ans[g / i - mn]++;
}
}
nowans++;
}
int las = l - 1;
for (int i = l; i <= r; i++) {
if (a[i] == mn) {
self(self, las + 1, i - 1);
las = i;
}
else if (i == r) {
self(self, las + 1, r);
}
}
};
merge(merge, 1, n);
int tmp = 0;
ll answer = 0;
for (auto [x, y] : ans) {
if (y == nowans) {
tmp++, answer += x;
}
}
cout << tmp << " " << answer << el;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int T = 1;
cin >> T;
while (T--) {
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3820kb
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: 0
Accepted
time: 0ms
memory: 3780kb
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 0 0 0 0 0 0
result:
ok 4 lines
Test #3:
score: 0
Accepted
time: 1ms
memory: 3488kb
input:
500 4 1000000000 8 14 24 18 4 1000000000 17 10 18 14 4 1000000000 6 17 19 19 4 1000000000 15 14 15 25 4 1000000000 16 16 5 25 4 1000000000 4 30 20 5 4 1000000000 11 4 23 9 4 1000000000 14 25 13 2 4 1000000000 18 18 1 15 4 1000000000 22 22 22 28 4 1000000000 15 17 17 10 4 1000000000 22 14 13 25 4 100...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 500 lines
Test #4:
score: 0
Accepted
time: 4ms
memory: 3500kb
input:
1 50000 1000000000 230 286458 41263680 41263680 41263680 41263680 41263680 41263680 41263680 41263680 41263680 41263680 41263680 41263680 41263680 41263680 41263680 41263680 41263680 41263680 41263680 41263680 41263680 41263680 41263680 41263680 41263680 41263680 41263680 41263680 41263680 41263680 ...
output:
0 0
result:
ok single line: '0 0'
Test #5:
score: 0
Accepted
time: 3ms
memory: 3544kb
input:
1 50000 1000000000 12087 1196491 55314643 55314643 55314643 55314643 55314643 55314643 55314643 55314643 55314643 55314643 55314643 55314643 55314643 55314643 55314643 55314643 55314643 55314643 55314643 55314643 55314643 55314643 55314643 55314643 55314643 55314643 55314643 55314643 55314643 553146...
output:
0 0
result:
ok single line: '0 0'
Test #6:
score: 0
Accepted
time: 4ms
memory: 3576kb
input:
1 50000 1000000000 2138984 42249920 358123541 358123541 358123541 358123541 358123541 358123541 358123541 358123541 358123541 358123541 358123541 358123541 358123541 358123541 358123541 358123541 358123541 358123541 358123541 358123541 358123541 358123541 358123541 358123541 358123541 358123541 3581...
output:
0 0
result:
ok single line: '0 0'
Test #7:
score: -100
Wrong Answer
time: 11ms
memory: 3556kb
input:
500 39 1000000000 75 7 7 381 41 1197 177 177 41 109 109 16 1197 177 41 381 1605 381 381 7 177 177 177 177 177 177 177 177 7 7 143 143 143 143 143 653 143 823 7 61 1000000000 327 327 327 327 405153474 327 405153474 327 810306621 810306621 810306621 810306621 810306621 810306621 810306621 810306621 81...
output:
0 0 25 631568356 13 18925862 11 2194 2 6878 1 2 1 1 2 10 3 6873 1 110 0 0 1 36 13 19290 1 29 1 4 6 2209209 0 0 3 8 1 2 9 30770061 1000000000 500000000500000000 1 3 0 0 0 0 1 5 1 1 6 6615501 3 8233825 2 1035 2 4 7 1288 0 0 1 3 16 1617883221 2 10 0 0 1 5739 15 102584 3 1100 0 0 2 4 3 11 0 0 0 0 7 4945...
result:
wrong answer 4th lines differ - expected: '1 1', found: '11 2194'