1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
#include <iostream> #include <cstdio> #include <cstring> //#include <fstream> #define ul unsigned long long using namespace std; int quotient[10005]; ul remainder; int main() { char num[10005]; char op[2]; int div; int pos; int j,k; //ofstream out; //out.open("out_10494.txt"); while(scanf("%s%s%d",num,op,&div)!=EOF) { k=0; remainder=0; for(int i=0;i<strlen(num);i++) { quotient[k] = 0; remainder = remainder*10+(num[i]-'0'); quotient[k] = remainder/div; remainder = remainder%div; k+=1; } if(op[0]=='/') { for(pos=0;pos<k && quotient[pos]==0 ;pos++) ; if(pos==k) printf("0\n"); //out<<"0\n"; else { while(pos<k) printf("%d",quotient[pos]), //out<<quotient[pos], pos+=1; printf("\n"); //out<<"\n"; } } else if(op[0]=='%') { printf("%llu\n",remainder); //out<<remainder<<"\n"; } } //out.close(); return 0; } |