QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#855762#9738. Make It DivisiblexuemanWA 1ms3668kbC++231.5kb2025-01-13 10:29:422025-01-13 10:29:42

Judging History

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

  • [2025-01-13 10:29:42]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3668kb
  • [2025-01-13 10:29:42]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
const int N = 1000 + 10;
const int maxn = 1e5 + 10;
const int inf = 0x3f3f3f3f;

int a[maxn];
ll n, m;
ll cnt, ans;

void check(int x)
{
    for (int i = 2; i <= n; i++)
    {
        int t1 = a[i] + x, t2 = a[i - 1] + x;
        if (t1 < t2)
            swap(t1, t2);
        if (t1 % t2 != 0)
            return;
    }
    ans += x;
    cnt++;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int T;
    cin >> T;
    while (T--)
    {
        cin >> n >> m;
        int mx = inf;
        for (int i = 1; i <= n; i++)
            cin >> a[i], mx = min(mx, a[i]);
        sort(a + 1, a + 1 + n);
        n = unique(a + 1, a + 1 + n) - a - 1;
        // cout << n << ' ';

        if (n == 1)
        {
            cout << m << ' ' << m * (m + 1) / 2 << endl;
            continue;
        }
        int g = 0;
        for (int i = 2; i <= n; i++)
            g = __gcd(a[i] - a[i - 1], g);
        cnt = ans = 0;
        for (int i = 1; i * i <= g; i++)
        {
            if (g % i == 0)
            {
                // cout << i << " " << g / i << endl;
                if (i - mx <= m && i - mx >= 1)
                    check(i - mx);
                if (i != g / i && g / i - mx <= m && g / i - mx >= 1)
                    check(g / i - mx);
            }
        }
        cout << cnt << ' ' << ans << endl;
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

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: 1ms
memory: 3668kb

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'