QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#855803#9738. Make It DivisiblexuemanWA 0ms3732kbC++231.7kb2025-01-13 10:59:252025-01-13 10:59:33

Judging History

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

  • [2025-01-13 10:59:33]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3732kb
  • [2025-01-13 10:59:25]
  • 提交

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;

    int tot = 178;
    while (T--)
    {
        tot++;
        cin >> n >> m;
        int mx = inf;
        for (int i = 1; i <= n; i++)
            cin >> a[i], mx = min(mx, a[i]);
        if (tot == 178)
        {
            cout << n << '|' << m << '|';
            for (int i = 1; i <= n; i++)
                cout << 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;
    }
}

详细

Test #1:

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

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

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
1 1
0 0
0 0

result:

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