|
import java.util.Scanner;
public class Test34 {
public static void Cal(long max) {
String str34[] = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
"A", "B", "C", "D", "E", "F", "G", "H", "J", "K", "L", "M",
"N", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" };
String result = "";
String tmpStr = "";
long tmpI;
int maxWS = 1;
int tmpWS;
tmpI = max;
// First judge the 34 digits of the input number
while (tmpI / 34> 34) {
maxWS++;
tmpI = tmpI / 34;
}
// increasing output
for (int i = 0; i <max; i++) {
tmpI = i;
tmpWS = maxWS;
result = "";
while (tmpWS> 0) {
tmpStr = str34[(int) Math.floor(tmpI
/ Math.pow(34, (double) tmpWS))];
result = result + tmpStr;
if (tmpStr != "0") {
tmpI = tmpI- (new Double(Math.floor(tmpI/ Math.pow(34, (double) tmpWS)))).longValue() * (new Double(Math.pow(34, (double) tmpWS))) .longValue();
}
tmpWS--;
}
result = result + str34[(int) i% 34];
System.out.println(result);
}
}
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
while (true) {
long num = in.nextLong();
if (num == 0) {
System.exit(0);
}
Cal(num);
}
}
}
Enter a decimal number arbitrarily, call the Cal() method to print the 34 decimal number incremented from 1 to the decimal number |
|