HDU 1212 Big Number

http://acm.hdu.edu.cn/showproblem.php?pid=1212

大整数取模问题

(a+b) mod n=((a mod n)+(b mod n)) mod n

View Code
#include <stdio.h>
#include <string.h>
int main()
{
    char s[1100];
    int n;
    int len,ans,i;
    while(~scanf("%s%d",s,&n))
    {
        len=strlen(s);
        ans=0;
        for(i=0;i<len;i++)
            ans=(ans*10+s[i]-'0')%n;
        printf("%d\n",ans);
    }
    return 0;
}
原文地址:https://www.cnblogs.com/xiaohongmao/p/2471743.html