QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#867051#9738. Make It DivisiblemeisgoodWA 0ms3840kbC++20953b2025-01-23 01:22:222025-01-23 01:22:22

Judging History

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

  • [2025-01-23 01:22:22]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3840kb
  • [2025-01-23 01:22:22]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MAXN=5e4+5, inf=1e16;
ll t, n, m, a[MAXN], g, s1, s2, mn;
void check(ll x){
  if(x<=mn||x-mn>m){
    return;
  }
  ll k=x-mn, flag=1;
  for(ll i=2; i<=n; i++){
    if(max(a[i]+k, a[i-1]+k)%min(a[i]+k, a[i-1]+k)!=0){
      flag=0;
      break;
    }
  }
  if(flag){
    s1++;
    s2+=k;
  }
}
int main(){
  scanf("%lld", &t);
  while(t--){
    scanf("%lld%lld", &n, &m);
    mn=inf;
    for(ll i=1; i<=n; i++){
      scanf("%lld", &a[i]);
      mn=min(mn, a[i]);
    }
    g=0;
    for(ll i=2; i<=n; i++){
      g=__gcd(g, abs(a[i]-a[i-1]));
    }
    if(g==0){
      printf("%lld %lld\n", m, m*(m+1)/2);
      continue;
    }
    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: 0ms
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'