/**//**************************************
Problem: HEU 1031 Basic Remains
Time: 0.0070 s
Memory: 536 k
Accepted Time: 2009-05-05 21:44:38
Tips: 转化成十进制,求余,在转化为X进制
**************************************/
#include <stdio.h>
#include <string.h>
int main()
{
int n;
while(scanf("%d",&n),n!&#61;0)
{
char a[1009],b[15];
scanf("%s%s",a,b);
int lena&#61;strlen(a),lenb&#61;strlen(b),i;
long long at&#61;0,bt&#61;0;
for(i&#61;0;i<lenb;i&#43;&#43;)bt&#61;bt*n&#43;b[i]-&#39;0&#39;;
for(i&#61;0;i<lena;i&#43;&#43;)
{
at&#61;at*n&#43;a[i]-&#39;0&#39;;
if(at>&#61;bt)at%&#61;bt;
}
if(at&#61;&#61;0)
{
printf("0\n");
continue;
}
int c[12];
for(i&#61;11;at!&#61;0;i--)
{
c[i]&#61;at%n;
at&#61;at/n;
}
for(i&#43;&#43;;i<12;i&#43;&#43;)printf("%d",c[i]);
printf("\n");
}
return 0;
}
Problem: HEU 1031 Basic Remains
Time: 0.0070 s
Memory: 536 k
Accepted Time: 2009-05-05 21:44:38
Tips: 转化成十进制&#xff0c;求余&#xff0c;在转化为X进制
**************************************/
#include <stdio.h>
#include <string.h>
int main()
{
int n;
while(scanf("%d",&n),n!&#61;0)
{
char a[1009],b[15];
scanf("%s%s",a,b);
int lena&#61;strlen(a),lenb&#61;strlen(b),i;
long long at&#61;0,bt&#61;0;
for(i&#61;0;i<lenb;i&#43;&#43;)bt&#61;bt*n&#43;b[i]-&#39;0&#39;;
for(i&#61;0;i<lena;i&#43;&#43;)
{
at&#61;at*n&#43;a[i]-&#39;0&#39;;
if(at>&#61;bt)at%&#61;bt;
}
if(at&#61;&#61;0)
{
printf("0\n");
continue;
}
int c[12];
for(i&#61;11;at!&#61;0;i--)
{
c[i]&#61;at%n;
at&#61;at/n;
}
for(i&#43;&#43;;i<12;i&#43;&#43;)printf("%d",c[i]);
printf("\n");
}
return 0;
}