QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#743877 | #9738. Make It Divisible | Sylvialline | Compile Error | / | / | C++14 | 1.3kb | 2024-11-13 20:12:52 | 2024-11-13 20:12:56 |
Judging History
你现在查看的是最新测评结果
- [2024-11-27 18:44:44]
- hack成功,自动添加数据
- (/hack/1263)
- [2024-11-14 09:10:13]
- hack成功,自动添加数据
- (/hack/1178)
- [2024-11-13 20:12:56]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2024-11-13 20:12:52]
- 提交
answer
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
void solve();
int main(){
int t=1;
cin>>t;
while(t--)solve();
}
const int N=5e4+3;
int a[N],g[N];
void solve(){
int n,k;
cin>>n>>k;
for(int i=1;i<=n;i++){
cin>>a[i];
}
if(n==1){
cout<<k<<" "<<k*(k+1ll)/2<<endl;
return;
}
vector<int>S;
a[n+1]=0;
int pos;
for(int i=1;i<=n+1;i++){
g[i]=0;
if(S.size()){
if(a[S.back()]>=a[i])g[i]=a[S.back()]-a[i];
else g[S.back()]=gcd(g[S.back()],a[i]-a[S.back()]);
}
int ng=0;
while(S.size()&&a[S.back()]>=a[i]){
ng=g[S.back()]=gcd(ng,g[S.back()]);
S.pop_back();
}
g[i]=gcd(g[i],ng);
S.push_back(i);
if(i==n)pos=S.front();
}
int ng=g[pos],mn=a[pos];
for(int i=1;i<=n;i++)cerr<<g[i]<<" \n"[i==n];
int cnt=0;
ll sum=0;
auto check=[&](int x){
if(x<=mn||x-mn>k)return;
x-=mn;
for(int i=1;i<=n;i++){
if(g[i]%(a[i]+x)!=0)return;
}
++cnt;
sum+=x;
};
for(int i=1;i*i<=ng;i++)if(ng%i==0){
check(i);
if(i*i!=ng)check(ng/i);
}
cout<<cnt<<" "<<sum<<endl;
}
詳細信息
answer.code: In function ‘void solve()’: answer.code:29:30: error: ‘gcd’ was not declared in this scope 29 | else g[S.back()]=gcd(g[S.back()],a[i]-a[S.back()]); | ^~~ answer.code:34:28: error: ‘gcd’ was not declared in this scope 34 | ng=g[S.back()]=gcd(ng,g[S.back()]); | ^~~ answer.code:37:14: error: ‘gcd’ was not declared in this scope 37 | g[i]=gcd(g[i],ng); | ^~~