mirror of
https://github.com/Kiritow/OJ-Problems-Source.git
synced 2024-03-22 13:11:29 +08:00
Create 1429.java
This commit is contained in:
parent
3757222b50
commit
54ad675a3b
24
QUSTOJ/1429.java
Normal file
24
QUSTOJ/1429.java
Normal file
|
@ -0,0 +1,24 @@
|
|||
import java.util.Scanner;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
Scanner in = new Scanner(System.in);
|
||||
int radix = in.nextInt();
|
||||
String s = in.next();
|
||||
StringBuffer s2 = new StringBuffer(s).reverse();
|
||||
int cnt = 0;
|
||||
long x = Long.valueOf(s, radix);
|
||||
while(!s2.toString().equals(s) && cnt <= 30){
|
||||
cnt++;
|
||||
x += Long.valueOf(s2.toString(), radix);
|
||||
s = Long.toString(x,radix);
|
||||
s2 = new StringBuffer(s).reverse();
|
||||
}
|
||||
if(cnt > 30){
|
||||
System.out.println("Impossible!");
|
||||
} else {
|
||||
System.out.println("STEP=" + cnt);
|
||||
}
|
||||
in.close();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user