比赛 2025.10.24 评测结果 AWWWWWWWWW
题目名称 小b爱取模 最终得分 10
用户昵称 会挽弯弓满月 运行时间 2.913 s
代码语言 C++ 内存使用 117.04 MiB
提交时间 2025-10-24 11:33:52
显示代码纯文本
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N=1e7+10;
ll k,n;
string s;
ll a[N],x[N];
ll ans;
int main(){
	freopen("changgao_modulo.in","r",stdin);
	freopen("changgao_modulo.out","w",stdout);
	scanf("%lld",&k);
	cin>>s;
	n=s.length();
    for(int i=0;i<n;i++) a[i]=s[i]-48;
    for(int i=1;i<=n;i++) x[i]=(k-a[i-1])%k;
    for(int i=1;i<=n+1;i++)
        if(x[i]>x[i-1])
            ans+=x[i]-x[i-1];
    printf("%lld",ans);
    return 0;
}