QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#795326#9738. Make It DivisibleNlll#WA 0ms3704kbC++20945b2024-11-30 19:42:062024-11-30 19:42:11

Judging History

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

  • [2024-11-30 19:42:11]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3704kb
  • [2024-11-30 19:42:06]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define FOR(i,j,k) for(int i=j;i<=k;++i)
#define For(i,j,k) for(int i=j;i>-k;--i)
const int N = 5e4+111;
int a[N],b[N];
int gcd(int x,int y){
	if(!x) return y;
	if(!y) return x;
	return gcd(y,x%y);
}
void sol(){
	int n,k;
	cin>>n>>k;
	FOR(i,1,n) cin>>a[i];
	sort(a+1,a+1+n);
	FOR(i,1,n) b[i] = a[i]-a[1];
	int d = 0;
	FOR(i,1,n) d = gcd(d,b[i]);
	int up = sqrt(d);
	int num = 0;
	if(d==0){
		cout<<k<<' '<<1ll*k*(k+1)/2;
		return;
	}
	long long sum = 0;
	long long tot = 0;
	FOR(i,1,up){
		if(d%i==0){
			if(i>a[1]&&(i-a[1])<=k){
				sum += i-a[1];
				++tot;
			}
			if(d!=i*i){
				if(d/i>a[1]&&(d/i-a[1])<=k){
					sum += d/i-a[1];
					++tot;
				}
			}
		}
	}
	cout<<tot<<' '<<sum<<'\n';
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t;
	cin>>t;
	while(t--){
		sol();
	}
	return 0;
}
/*
1 
2 100
2 20
*/ 

詳細信息

Test #1:

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

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

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'