QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#864859#9738. Make It Divisiblec20220526WA 0ms3840kbC++14883b2025-01-21 09:59:292025-01-21 09:59:30

Judging History

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

  • [2025-01-21 09:59:30]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3840kb
  • [2025-01-21 09:59:29]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=5e4+5;
int t,n,b[N],a[N],d[N],ans1,ans2,m,ok;
inline void chk(int k){
	if(k>m||k<1) return;
	for(int j=1;j<n;j++) if(a[j]%(d[j]+k)) return;
	ans1++,ans2+=k; 
}
void check(int x,int y){
	for(int i=1;i*i<x;i++)
		if(x%i==0) chk(i-y),chk(x/i-y);
	chk(sqrt(x)-y);
}
signed main(){
	scanf("%lld",&t);
	while(t--){
		scanf("%lld%lld",&n,&m); ans1=ans2=ok=0;
		for(int i=1;i<=n;i++) scanf("%lld",&b[i]);
		for(int i=1;i<n;i++) a[i]=abs(b[i+1]-b[i]),d[i]=min(b[i],b[i+1]);
		for(int i=1;i<n;i++) if(a[i]&&!ok) check(a[i],d[i]),ok=1;
		if(!ok) printf("%lld %lld\n",m,m*(m+1)/2);
		else printf("%lld %lld\n",ans1,ans2);
	}
	return 0;
}
/*
a[i]=b[i+1]-b[i],d[i]=min(b[i],b[i+1])
找到所有 x,使得任意 (d[i]+x)|a[i] 
3
5 10
7 79 1 7 1
2 1000000000
1 2
1 100
1000000000
*/

詳細信息

Test #1:

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

input:

3
5 10
7 79 1 7 1
2 1000000000
1 2
1 100
1000000000

output:

4 9
0 0
100 5050

result:

wrong answer 1st lines differ - expected: '3 8', found: '4 9'