Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class quorum {
- public static void main(String[] args) {
- Scanner s = new Scanner(System.in);
- int N;
- int Q;
- int counter;
- while (true) {
- counter = 0;
- N = s.nextInt();
- Q = s.nextInt();
- if (N==0 & Q==0)break;
- for (int i=0; i<N; i++) {
- int suma = i + capicuo(i);
- if (suma >= Q && suma <= N) counter++;
- }
- System.out.println(N + " " + Q + " "+counter);
- }
- }
- public static int capicuo(Integer a) {
- String st = a.toString();
- switch (st.length()) {
- case 1:
- st = "000" + st;
- break;
- case 2:
- st = "00" + st;
- break;
- case 3:
- st = "0" + st;
- break;
- }
- st = ""+st.charAt(3)+st.charAt(2)+st.charAt(1)+st.charAt(0);
- return Integer.parseInt(st);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement