1103: PIPI的数学题I
使用同余定理
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
char n[10010];
ll p;
int main(){
while(scanf("%s%d",n+1,&p)!=EOF){
//cout<<n+1<<p;
int l=strlen(n+1);
ll ans=0;
for(int i=1;i<=l;i++){
ans=((ans*10)%p+n[i]-'0')%p;
}
printf("%lld\n",ans);
}
return 0;
}

浙公网安备 33010602011771号