#include<bits/stdc++.h>
using namespace std;
main()
{
char s[1000]={0};
while(cin>>s)
{
long long b,c,sum=0;
scanf("%lld%lld",&b,&c);
long long ar[10000]={0},k=0,i;
long long k2=0,ar1[10000]={0},k1,sum1=0;
for(i=0;i<strlen(s);i++)
{
if(isalpha(s[i]))
{
ar[k++]=s[i]-55;
}
else
ar[k++]=s[i]-48;
}
for(i=0;i<k;i++)
{
sum=sum+ar[i]*pow(b,k-i-1)+.00000001;
}
k=0;
do
{
ar1[k++]=sum%c;
sum=sum/c;
}
while(sum!=0);
//cout<<k<<endl;
if(k>7)
{
cout<<" ERROR"<<endl;
}
else
{
for(i=1;i<=7-k;i++)
cout<<" ";
for(i=k-1;i>=0;i--)
{
if(ar1[i]<10)
cout<<ar1[i];
else
cout<<(char)(ar1[i]+55);
}
cout<<endl;
}
}
}
using namespace std;
main()
{
char s[1000]={0};
while(cin>>s)
{
long long b,c,sum=0;
scanf("%lld%lld",&b,&c);
long long ar[10000]={0},k=0,i;
long long k2=0,ar1[10000]={0},k1,sum1=0;
for(i=0;i<strlen(s);i++)
{
if(isalpha(s[i]))
{
ar[k++]=s[i]-55;
}
else
ar[k++]=s[i]-48;
}
for(i=0;i<k;i++)
{
sum=sum+ar[i]*pow(b,k-i-1)+.00000001;
}
k=0;
do
{
ar1[k++]=sum%c;
sum=sum/c;
}
while(sum!=0);
//cout<<k<<endl;
if(k>7)
{
cout<<" ERROR"<<endl;
}
else
{
for(i=1;i<=7-k;i++)
cout<<" ";
for(i=k-1;i>=0;i--)
{
if(ar1[i]<10)
cout<<ar1[i];
else
cout<<(char)(ar1[i]+55);
}
cout<<endl;
}
}
}
কোন মন্তব্য নেই:
একটি মন্তব্য পোস্ট করুন