大整数求余
对于大整数(此处指长度超过100的一组以数字组成的字符串),求出这个数对于某个数字n的余数;
1 #include<stdio.h> 2 #include<iostream> 3 #include<algorithm> 4 #include<string.h> 5 using namespace std; 6 int main() 7 { 8 int n; 9 char s[105]; 10 while(cin>>s){ 11 12 cin>>n; 13 int m=0; 14 for(int i=0;i<strlen(s);i++){ 15 m=m*10+s[i]-'0'; 16 m%=n; 17 } 18 if(m==0)cout<<"Yes"<<endl; 19 else cout<<m<<endl; 20 21 } 22 }
你若盛开,清风自来...