-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwhatbase.cpp
More file actions
36 lines (33 loc) · 722 Bytes
/
whatbase.cpp
File metadata and controls
36 lines (33 loc) · 722 Bytes
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
#include <iostream>
using namespace std;
int baseconversion(int n, int base){
int total=0, multfact=1;
while(n>0){
total+=(n%10)*multfact;
multfact*=base;
n/=10;
}
return total;
}
int main(){
int n;
cin >> n;
for(int i=0; i<n; i++){
int x=10, y=10, num1, num2;
cin >> num1 >> num2;
int newnum1=num1;
int newnum2=num2;
while(newnum1!=newnum2){
newnum1=baseconversion(num1, x);
newnum2=baseconversion(num2, y);
if(newnum1<newnum2){
x++;
}
else{
y++;
}
}
cout << x << " " << y-1 << endl;
}
return 0;
}