QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#867040#9738. Make It DivisiblemeisgoodWA 1ms3840kbC++20803b2025-01-23 01:04:322025-01-23 01:04:33

Judging History

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

  • [2025-01-23 01:04:33]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3840kb
  • [2025-01-23 01:04:32]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MAXN=5e4+5;
ll t, n, m, a[MAXN], g, s1, s2;
void check(ll x){
  if(x<=a[1]||x>m){
    return;
  }
  ll k=x-a[1];
  if((a[2]+k)%(a[1]+k)==0){
    s1++;
    s2+=k;
  }
}
int main(){
  scanf("%lld", &t);
  while(t--){
    scanf("%lld%lld", &n, &m);
    for(ll i=1; i<=n; i++){
      scanf("%lld", &a[i]);
    }
    if(n==1){
      printf("%lld %lld\n", m, m*(m+1)/2);
      continue;
    }
    sort(a+1, a+n+1);
    g=0;
    for(ll i=2; i<=n; i++){
      g=__gcd(g, a[i]-a[i-1]);
    }
    s1=s2=0;
    for(ll i=1; i<=sqrt(g); i++){
      if(g%i==0){
        check(i);
        if(i*i!=g){
          check(g/i);
        }
      }
    }
    printf("%lld %lld\n", s1, s2);
  }
  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

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'