把10进制转化为(p/q)进制。
每一位均为整数。
每一步让n对(p/q)取模,保证余数为正数即可。
即找到小于n的数中,能整除(p/q)且最大的数。
直接n/p*q 的结果就是。 余数是n%p
倒着放位数即可。
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ls (o<<1)
#define rs (o<<1|1)
#define pb push_back
const double PI= acos(-1.0);
const int M = 1e5+7;
/*
int head[M],cnt;
void init(){cnt=0,memset(head,0,sizeof(head));}
struct EDGE{int to,nxt,val;}ee[M*2];
void add(int x,int y){ee[++cnt].nxt=head[x],ee[cnt].to=y,head[x]=cnt;}
*/
char s[100]={"0123456789"};
int a[110];
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int p,q,n,sz=0;
cin>>p>>q>>n;
while(n)
{
a[++sz]=n%p;
n=n/p*q;
}
for(int i=sz;i>=1;i--)
{
char tp;
if(a[i]<=9)tp='0'+a[i];
else if(a[i]<=35)tp='A'+a[i]-10;
else tp='a'+a[i]-36;
cout<<tp;
}
cout<<endl;
return 0;
}