比赛 2025.10.24 评测结果 WWWWWWWWWW
题目名称 小b爱取模 最终得分 0
用户昵称 梦那边的美好ME 运行时间 3.160 s
代码语言 C++ 内存使用 63.54 MiB
提交时间 2025-10-24 11:47:51
显示代码纯文本
#include <bits/stdc++.h>
using namespace std;
#define ll long long

ll k,a[11000000],ans;
string s;
ll n;

int main(){
	freopen("changgao_modulo.in","r",stdin);
	freopen("changgao_modulo.out","w",stdout);
	cin>>k>>s;
	s=' '+s;
	n=s.length()-1;
	a[1]=s[1]-'0';
	a[1]=(a[1]/k+1)*k-a[1];
	for (int i=2;i<=n;i++){
		a[i]=s[i]-'0';
		a[i]=(a[i]/k+1)*k-a[i];
		if (a[i]>a[i-1]){
			ans+=a[i]-a[i-1];
		}
	}
	printf("%lld",ans+a[1]);
    return 0;
}