标签:des style blog color os io for ar
2 1100 101 10 123456789123456789123456789 1000 0
10 789
#include<iostream> #include <cstring> #include <stdlib.h> #include <cstdio> #include <map> #include <algorithm> using namespace std; int low(int a,int b) { int s=1,r=1; while(b!=0) { if(b&1) r*=a; a=a*a; b>>=1; } return r; } __int64 zhuanhuan(__int64 a,int b) { __int64 sum=0,i=1; // cout<<a<<"---"<<endl; while(a) { sum+=(a%10)*i; a=a/10; i*=b; } return sum; } __int64 er(__int64 a,int b) { __int64 m=0,i=0; int aa[20]={0}; if(a==0){printf("0\n");return 0;} while(a) { aa[i++]=a%b; a=a/b; } for(int j=i-1;j>=0;j--) printf("%d",aa[j]); printf("\n"); return 0; } int main() { int a,m,l; char str[10000]; while(cin>>a) { if(a==0)break; cin>>str>>m; __int64 sm=0,cm=1; __int64 sb=zhuanhuan(m,a); l=strlen(str); { for(int i=l-1;i>=0;i--) { sm=(sm+(str[i]-'0')*cm)%sb; cm=(cm*a)%sb; } } __int64 cb=sm%sb; er(cb,a); } return 0; }
标签:des style blog color os io for ar
原文地址:http://blog.csdn.net/zhangweiacm/article/details/38616103