1 /**2016中国大学生程序设计网络赛赛HDU 2 1001大数求余 3 */ 4 5 #include "iostream" 6 #include "cstdio" 7 #include "cstring" 8 using namespace std; 9 char s[100000002]; 10 int main() { 11 12 int t=1; 13 while(~scanf("%s", &s)) { 14 15 int m = 0,n=0; 16 for(int i = 0; i <strlen(s); i++) 17 { 18 m = (m*10+s[i]-'0')%73; 19 n = (n*10+s[i]-'0')%137; 20 } 21 22 if(m==0&&m==0) 23 { 24 printf("Case #%d: YES ",t); 25 }else{ 26 printf("Case #%d: NO ",t); 27 } 28 t++; 29 } 30 return 0; 31 }
///大整数取模
/**
输入正整数n m输出n mod m n<=10^100 m<=10^9
*/
将大整数写成自左向右形式:1234=((1*10+2)*10+3)*10+4
1 #include "cstdio" 2 #include "cstring" 3 #include "cstdlib" 4 using namespace std; 5 int main() 6 { 7 char n[101]; 8 int m; 9 while(~scanf("%s%d",n,&m)&&m) 10 { 11 int len=strlen(n); 12 int ans=0; 13 for(int i=0;i<len;i++) 14 ans=(int)(((long long)ans*10+n[i]-'0')%m); 15 printf("%d ",ans); 16 } 17 return 0; 18 }