QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#739876#9738. Make It Divisibleremain11WA 1ms5904kbC++201.7kb2024-11-12 23:38:392024-11-12 23:38:40

Judging History

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

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

answer

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <queue>
#include <map>
#include <set>
using namespace std;
using ll=long long;
const int maxn=2e5+5;
const ll mod=998244353;
ll a[maxn], b[maxn];
int t=1,tt=1;
void solve() {
    ll n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        b[i] = a[i];
    }
    if(t==2&&tt==4) {
        for(int i=1;i<=n;i++)
            cout<<a[i]<<0;
        cout<<"\n";
        return;
    }
    sort(b + 1, b + 1 + n);
    if (b[1] == b[n]) {
        cout <<k << " " << (k + 1) * k / 2 << '\n';
        return;
    }
    int x, y;
    for (int i = 2; i <= n; i++) {
        if (b[i - 1] != b[i]) {
            x = b[i - 1];
            y = b[i];
            break;
        }
    }
    int m = y - x;
    set<int> st;
    for (ll i = 1; i * i <= m; i++) {
        if (m % i == 0) {
            int res = m / i - x;
            if (res <= k && res >= 1) st.insert(res);
            if (m / i != i) {
                res = i - x;
                if (res <= k && res >= 1) st.insert(res);
            }
        }
    }
    for(int i=1;i<n;i++) {
        for(auto it=st.begin();it!=st.end();) {
            auto it2=it;
            it2++;
            int x=a[i],y=a[i+1];
            if(x>y) swap(x, y);
            if((y+*it)%(x+*it))
                st.erase(it);
            it=it2;
        }
    }
    cout<<st.size()<<" ";
    ll sum=0;
    for(auto now:st)
        sum+=now;
    cout<<sum<<"\n";
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>t;
    tt=t;
    while (t--) {
        solve();
    }
    return 0;
}

詳細信息

Test #1:

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

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

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

result:

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