QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#747893#9738. Make It DivisibleSSAABBEERRWA 1ms3780kbC++201.3kb2024-11-14 18:38:082024-11-14 18:38:09

Judging History

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

  • [2024-11-27 18:44:44]
  • hack成功,自动添加数据
  • (/hack/1263)
  • [2024-11-14 18:38:09]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3780kb
  • [2024-11-14 18:38:08]
  • 提交

answer

#include<bits/stdc++.h>
#define endl '\n'
#define int long long
#define rep(i, a, b) for(int i = a; i <= b; i ++ )
#define pre(i, a, b) for(int i = a; i >= b; i -- )
using namespace std;
const int N = 1e6 + 10;
int n, m, k;
int a[N];
void solve()
{
    cin >> n >> m;
    rep(i, 1, n) cin >> a[i];
    if(n == 1)
    {
        cout << m << " " << m * (1 + m) / 2 << endl;
        return;
    }
    int w = 0, ma = 1e18;
    rep(i, 1, n) ma = min(ma, a[i]);
    rep(i, 1, n - 1)
    {
        int x = a[i], y = a[i + 1];
        if(x == y) continue;
        if(x > y) swap(x, y);
        if(!w) w = y - x;
        else w = __gcd(w, y - x);
    }
    if(!ma)
    {
        cout << m << " " << m * (1 + m) / 2 << endl;
        return;
    }
    int sum = 0, ans = 0;
    rep(i, 1, sqrt(w))
    {
        if(w % i != 0) continue;
        if(i > ma && i - ma <= m) sum ++ , ans += i - ma;
        if(w / i != i)
        {
            if(w / i > ma && w / i - ma <= m) sum ++ , ans += (w / i - ma);
        }
    }
    cout << sum << " " << ans << endl;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int _;
    _ = 1;
    cin >> _;
    while(_ -- )
    {
        solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3780kb

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

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'