QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#864854 | #9738. Make It Divisible | c20220526 | WA | 1ms | 3840kb | C++14 | 909b | 2025-01-21 09:55:26 | 2025-01-21 09:55:27 |
Judging History
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'