#include<bits/stdc++.h>
using namespace std;
long i;
long decimal_a_rupantor(long base1,string s)
{
long power=0,no;
long gap,n=0;
for(i=s.size()-1; i>=0; i--)
{
gap=pow(base1,power)+.0000000001;
no=s[i]-48;
n+=no*gap;
power++;
}
return n;
}
using namespace std;
main()
{
long base;
string p,m;
while(cin>>base)
{
if(base==0)
break;
else
{
cin>>p>>m;
long len=p.size();
long a=decimal_a_rupantor(base,m);//m ke decimal a rupantor
string ss="";
long sum=0,ar[100010]={0},k=0;
for (i=0; i<p.length(); i++)
{
sum=sum*base;
sum+=p[i]-48;
sum=sum%a;
}
if(sum==0)
cout<<0<<endl;
else
{
while(sum!=0)
{
ar[k++]=sum%base;
sum/=base;
}
for(i=k-1;i>=0;i--)
{
cout<<ar[i];
}
cout<<endl;
}
}
}
}
using namespace std;
long i;
long decimal_a_rupantor(long base1,string s)
{
long power=0,no;
long gap,n=0;
for(i=s.size()-1; i>=0; i--)
{
gap=pow(base1,power)+.0000000001;
no=s[i]-48;
n+=no*gap;
power++;
}
return n;
}
using namespace std;
main()
{
long base;
string p,m;
while(cin>>base)
{
if(base==0)
break;
else
{
cin>>p>>m;
long len=p.size();
long a=decimal_a_rupantor(base,m);//m ke decimal a rupantor
string ss="";
long sum=0,ar[100010]={0},k=0;
for (i=0; i<p.length(); i++)
{
sum=sum*base;
sum+=p[i]-48;
sum=sum%a;
}
if(sum==0)
cout<<0<<endl;
else
{
while(sum!=0)
{
ar[k++]=sum%base;
sum/=base;
}
for(i=k-1;i>=0;i--)
{
cout<<ar[i];
}
cout<<endl;
}
}
}
}
কোন মন্তব্য নেই:
একটি মন্তব্য পোস্ট করুন