forked from MiYazJE/Acepta-el-reto
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathp115.java
62 lines (36 loc) · 740 Bytes
/
p115.java
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import java.util.Scanner;
public class p115 {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int num;
int left;
int right;
int decima;
int suma;
boolean kapkrekar;
num = s.nextInt();
while(num != 0) {
decima = 1;
left = 0;
right = 0;
suma = 0;
kapkrekar = false;
left = num * num;
while(left > 0 && !kapkrekar) {
right = right + (left % 10) * decima;
left /= 10;
decima *= 10;
suma = left + right;
if(right > 0 && suma == num) {
kapkrekar = true;
}
}
if(kapkrekar == true) {
System.out.println("SI");
} else if (kapkrekar == false) {
System.out.println("NO");
}
num = s.nextInt();
}
}
}