QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#867048#9738. Make It DivisiblemeisgoodWA 1ms3840kbC++20932b2025-01-23 01:16:162025-01-23 01:16:16

Judging History

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

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

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-a[1]>m){
    return;
  }
  ll k=x-a[1], flag=1;
  for(ll i=2; i<=n; i++){
    if((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);
    for(ll i=1; i<=n; i++){
      scanf("%lld", &a[i]);
    }
    sort(a+1, a+n+1);
    n=unique(a+1, a+n+1)-a-1;
    if(n==1){
      printf("%lld %lld\n", m, m*(m+1)/2);
      continue;
    }
    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;
}

詳細信息

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: 0
Accepted
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
0 0
0 0
0 0

result:

ok 4 lines

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 3840kb

input:

500
4 1000000000
8 14 24 18
4 1000000000
17 10 18 14
4 1000000000
6 17 19 19
4 1000000000
15 14 15 25
4 1000000000
16 16 5 25
4 1000000000
4 30 20 5
4 1000000000
11 4 23 9
4 1000000000
14 25 13 2
4 1000000000
18 18 1 15
4 1000000000
22 22 22 28
4 1000000000
15 17 17 10
4 1000000000
22 14 13 25
4 100...

output:

0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
...

result:

wrong answer 178th lines differ - expected: '1 2', found: '0 0'