2019-05-09 19:32:54 +08:00
|
|
|
package Conversions;
|
2018-04-02 03:09:06 +08:00
|
|
|
|
2017-10-04 00:37:30 +08:00
|
|
|
import java.util.Scanner;
|
2017-10-23 14:18:18 +08:00
|
|
|
//given a source number , source base, destination base, this code can give you the destination number.
|
|
|
|
//sn ,sb,db ---> ()dn . this is what we have to do .
|
2017-10-04 00:37:30 +08:00
|
|
|
|
2018-04-02 03:09:06 +08:00
|
|
|
public class AnytoAny {
|
|
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
Scanner scn = new Scanner(System.in);
|
|
|
|
int sn = scn.nextInt();
|
|
|
|
int sb = scn.nextInt();
|
|
|
|
int db = scn.nextInt();
|
|
|
|
int m = 1, dec = 0, dn = 0;
|
|
|
|
while (sn != 0) {
|
|
|
|
dec = dec + (sn % 10) * m;
|
|
|
|
m *= sb;
|
|
|
|
sn /= 10;
|
|
|
|
}
|
|
|
|
m = 1;
|
|
|
|
while (dec != 0) {
|
|
|
|
dn = dn + (dec % db) * m;
|
|
|
|
m *= 10;
|
|
|
|
dec /= db;
|
|
|
|
}
|
|
|
|
System.out.println(dn);
|
2020-01-29 00:34:52 +08:00
|
|
|
scn.close();
|
2018-04-02 03:09:06 +08:00
|
|
|
}
|
2017-10-04 00:37:30 +08:00
|
|
|
|
|
|
|
}
|