QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#791949#9738. Make It DivisibleEqvpkbzWA 0ms3548kbC++231.7kb2024-11-28 22:16:532024-11-28 22:16:54

Judging History

你现在查看的是最新测评结果

  • [2024-11-28 22:16:54]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3548kb
  • [2024-11-28 22:16:53]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const ll N = 3e5 + 5;
const ll P = 998244353;
ll n, m, k;
void solve() {
    cin >> n >> k;
    vector<int> b(n + 2);
    int mn = 1e9;
    for (int i = 1; i <= n; i++) {
        cin >> b[i];
        mn = min(mn, b[i]);
    }
    int now = 0;
    for (int i = 1; i <= n; i++) {
        now = __gcd(b[i] - mn, now);
    }
    if (now == 0) {
        cout << k << ' ' << (k + 1) * (k) / 2 << '\n';
        return;
    }
    vector<int> ve;
    for (ll i = 1; i * i <= now; i++) {
        if (now % i == 0) {
            if (i > mn && i - mn <= k) {
                ve.push_back(i - mn);
            }
            if ((now / i) > mn && (now / i) != i && (now / i) - mn <= k) {
                ve.push_back((now / i) - mn);
            }
        }
    }
    ll sum = 0, ans = 0;
    for (auto x : ve) {
        int fg = 1;
        // cout << x << "\n";
        for (int i = 1; i < n; i++) {
            int d = __gcd(b[i] + x, b[i + 1] + x);
            if (d != b[i] + x && d != b[i + 1] + x) {
                fg = 0;
                break;
            }
        }
        for (int i = 1; i < n - 1; i++) {
            int d = __gcd(b[i] + x, b[i + 2] + x);
            if (d != b[i] + x && d != b[i + 2] + x) {
                fg = 0;
                break;
            }
        }
        if (fg) {
            sum++;
            ans += x;
        }
    }
    cout << sum << ' ' << ans << '\n';
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int _ = 1;
    cin >> _;
    while (_--) {
        solve();
    }
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3548kb

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: 3484kb

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: -100
Wrong Answer
time: 0ms
memory: 3548kb

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:

wrong answer 178th lines differ - expected: '1 2', found: '0 0'