QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#790028#9738. Make It Divisibleqfl_zzz#WA 0ms3824kbC++231.4kb2024-11-27 23:44:482024-11-27 23:44:49

Judging History

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

  • [2024-11-27 23:44:49]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3824kb
  • [2024-11-27 23:44:48]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define vv vector
#define ll long long
const int N = 200000 + 5;
const int P = 1e9 + 7;
const ll inf = 1e18;

mt19937_64 gen(chrono::steady_clock::now().time_since_epoch().count());
uniform_int_distribution<ll> rd(0, 1e9);
inline ll rnd() { return rd(gen); }

void qfl_zzz()
{
    ll n, k;
    cin >> n >> k;
    vv<ll> a(n + 1);
    for (ll i = 1; i <= n; ++i)
        cin >> a[i];
    sort(a.begin() + 1, a.end());

    if (n == 1)
    {
        cout << k << " " << k * (k + 1) / 2 << "\n";
        return;
    }

    ll g = 0;
    for (ll i = 2; i <= n; ++i)
        g = __gcd(g, a[i] - a[i - 1]);

    set<ll> s;
    auto upd = [&](ll d)
    {
        ll x = d - a[1];
        if (1 <= x && x <= k)
            s.insert(x);
    };
    for (ll i = 1; i * i <= g; ++i)
        if (g % i == 0)
        {
            upd(i);
            if (i * i != g)
                upd(g / i);
        }

    ll cnt = 0, sum = 0;
    for (ll x : s)
        ++cnt, sum += x;
    cout << cnt << " " << sum << "\n";
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    srand(unsigned(time(0)));
    cout << setiosflags(ios::fixed) << setprecision(12);

#ifdef LOCAL
    freopen("in.txt", "r", stdin);
    freopen("std.txt", "w", stdout);
#endif

    int T = 1;
    cin >> T;
    while (T--)
        qfl_zzz();

    return 0;
}

详细

Test #1:

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

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

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'