-
Notifications
You must be signed in to change notification settings - Fork 0
/
DOICOSO.cpp
48 lines (48 loc) · 923 Bytes
/
DOICOSO.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include<stdio.h>
#include<math.h>
#include<string.h>
#define f0(i,n) for(int i=0;i<n;i++)
#define f1(i,n) for(int i=1;i<=n;i++)
const char CHAR55=55;
const char CHAR48=48;
typedef long long ll;
const int N=1e6+3;
void xuly()
{
int n,b;
scanf("%d%d",&n,&b);
int i;
char a[25];
int cou=0,m,nho=n;
while(nho>0)
{
if(b>10)
{
m=nho%b;
if(m>=10)
{
a[cou]=(char)(m+CHAR55);
cou++;
}
else
{
a[cou]=(char)(m+CHAR48);
cou++;
}
}
else
{
a[cou]=(char)((nho%b)+CHAR48);
cou++;
}
nho=nho/b;
}
for(int i=cou-1;i>=0;i--) printf("%c",a[i]);
printf("\n");
}
int main()
{
int t;
scanf("%d",&t);
while(t--) xuly();
}