大数除法的改编版,大数求余
#include<iostream> #include<string> #include<algorithm> using namespace std; //本题是大整数除法 int divideString(string a,int x) { int remainder=0; for(int i=0;i<a.size();i++) { int num=remainder*10+a[i]-'0'; a[i]=num/x+'0'; remainder=num%x; } if(remainder) return remainder; return 0; } using namespace std; int main() { string c; while(cin>>c) { if(c=="-1") break; int sum=0; for(int i=2;i<10;i++) { //cout<<"div:"<<divideString(c,i)<<endl; if(divideString(c,i)==0) { printf("%d ",i); sum++; } } if(!sum) printf("none\n"); else printf("\n"); } return 0; }