题解 | #小乐乐与进制转换#
小乐乐与进制转换
http://www.nowcoder.com/practice/242eafef2a704c0ca130d563b7b3ee2d
import java.util.Scanner;
// 除基数取余,直到商为0,余数反转
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
long n = sc.nextInt();
long sum = 0;
long count = 0;
while (true) {
if (n / 6 == 0) {
sum += (long)Math.pow(10, count) * (n % 6);
break;
}
sum += (long)Math.pow(10, count) * (n % 6);
n = n / 6;
count ++;
}
System.out.println(sum);
}
}