QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#864854#9738. Make It Divisiblec20220526WA 1ms3840kbC++14909b2025-01-21 09:55:262025-01-21 09:55:27

Judging History

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

  • [2025-01-21 09:55:27]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3840kb
  • [2025-01-21 09:55:26]
  • 提交

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){
	x=abs(x);
	for(int i=1;i*i<=x;i++)
		if(x%i==0){
			chk(i-y);
			if(i*i!=x) chk(x/i-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]=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;
}
/*
know a,d
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: 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:

1 1
1 1
1 1
1 1

result:

wrong answer 1st lines differ - expected: '0 0', found: '1 1'