QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#801165#9738. Make It DivisibleProaesWA 1ms3576kbC++111.3kb2024-12-06 18:51:502024-12-06 18:51:50

Judging History

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

  • [2024-12-06 18:51:50]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3576kb
  • [2024-12-06 18:51:50]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;

#define ll long long

void solve(){
    ll n , k ;cin>>n>>k;
    vector<ll> a(n);
    for(ll&x:a) cin>>x;
    ll mx = *max_element(a.begin(),a.end());
    ll mi = *min_element(a.begin(),a.end());
    if(mx == mi){
        cout<<k<<" ";
        cout<<(1 + k) * k /2<<endl;
        return;
    }
    vector<ll> ck;
    ll yd = 0;
    for(ll i =0;i<n - 1;i++){
        if(a[i] == a[i+1]) continue;
        mx = max(a[i] ,a[i+1]);
        mi = min(a[i] ,a[i+1]);
        yd = mi;
        ll d = mx - mi;
        for(ll i = 1;i*i<=d;i++){
            if(d % i == 0){
                ck.push_back(i);
                if(i*i!=d) ck.push_back(d/i);
            }
        }
        break;
    }
    vector<ll> ans;
    ll ans1= 0 ,ans2 = 0;
    mi = *min_element(a.begin(),a.end());
    for(ll x : ck){
        ll g = 0;
        x -= yd;
        if(x <= 0) continue;
        // cout<<x<<" ";
        for(ll y : a) g = __gcd(1ll * g , 0ll + y + x );
        if(g == mi + x && x<=k && 1<=x){
            ans1 ++; ans2 += x;
        }
    }
    cout<<ans1<<" "<<ans2<<endl;
}

signed main(){
    cin.tie(0);cout.tie(0);
    ios::sync_with_stdio(0);
    ll t;cin>>t;while(t--)
        solve();
}

详细

Test #1:

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

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

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'