You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
460 B
28 lines
460 B
#include <bits/stdc++.h>
|
|
|
|
using namespace std;
|
|
const int N = 110;
|
|
int a[N], al;
|
|
|
|
void check(int n,int m){
|
|
al = 0;
|
|
while(n){
|
|
int x = n % m;
|
|
a[++al] = x;
|
|
n /= m;
|
|
}
|
|
for (int i = al; i >= 1; i--){
|
|
printf("%d", a[i]);
|
|
}
|
|
puts("");
|
|
}
|
|
int main() {
|
|
int n;
|
|
cin >> n;
|
|
int a, b;
|
|
for (int i = 1; i <= n;i++){
|
|
cin >> a >> b;
|
|
check(a, b);
|
|
}
|
|
return 0;
|
|
} |