| 比赛 |
2025.10.24 |
评测结果 |
AWWWWWWWWW |
| 题目名称 |
小b爱取模 |
最终得分 |
10 |
| 用户昵称 |
梦那边的美好TE |
运行时间 |
1.106 s |
| 代码语言 |
C++ |
内存使用 |
37.23 MiB |
| 提交时间 |
2025-10-24 11:48:00 |
显示代码纯文本
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
const int N=1e7+10;
int k,n,a[N],ans;
char s[N];
int main(){
freopen("changgao_modulo.in","r",stdin);
freopen("changgao_modulo.out","w",stdout);
scanf("%d",&k);
scanf("%s",s+1);
n=strlen(s+1);
for(int i=1;i<=n;i++)a[i]=s[i]-'0';
for(int i=n;i>=1;i--){
a[i]=a[i]-a[i-1];
a[i]=(a[i]%k+k)%k;
}
int cnt=0;
for(int i=1;i<=n;i++){
if(cnt>=a[i]){
cnt-=a[i];
}else{
cnt+=k-a[i];
ans+=k-a[i];
}
}
printf("%d\n",ans);
return 0;
}