/********************************************************
** Highlight software by yzfy(雨中飞燕) http:// *
*********************************************************/
#include<stdio.h>
#include<string.h>
char out[100000]={0};
int main(void)
{
int q=0;
char sp[50];
while (scanf(" %s%d", sp, &q)!=EOF)
{
char* ps=out;
int s=0,l=0;
strcpy(out, sp);
ps += l = (int)strlen(sp);
for (char* ps1=out;;++ps,++ps1)
{
int t = s*10+(*ps1-'0');
s = t%q; *ps = t/q+'0';
if (s==0 && strncmp(sp, ps-l+1, l)==0)
break;
}
ps[1]=0;
printf("%s\n", out+l);
}
return 0;
}
** Highlight software by yzfy(雨中飞燕) http:// *
*********************************************************/
#include<stdio.h>
#include<string.h>
char out[100000]={0};
int main(void)
{
int q=0;
char sp[50];
while (scanf(" %s%d", sp, &q)!=EOF)
{
char* ps=out;
int s=0,l=0;
strcpy(out, sp);
ps += l = (int)strlen(sp);
for (char* ps1=out;;++ps,++ps1)
{
int t = s*10+(*ps1-'0');
s = t%q; *ps = t/q+'0';
if (s==0 && strncmp(sp, ps-l+1, l)==0)
break;
}
ps[1]=0;
printf("%s\n", out+l);
}
return 0;
}
My solution
" border="0" />[color=white]