Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class quorum {
  4.  
  5. public static void main(String[] args) {
  6. Scanner s = new Scanner(System.in);
  7. int N;
  8. int Q;
  9. int counter;
  10. while (true) {
  11. counter = 0;
  12. N = s.nextInt();
  13. Q = s.nextInt();
  14.  
  15. if (N==0 & Q==0)break;
  16. for (int i=0; i<N; i++) {
  17. int suma = i + capicuo(i);
  18. if (suma >= Q && suma <= N) counter++;
  19. }
  20. System.out.println(N + " " + Q + " "+counter);
  21. }
  22.  
  23.  
  24. }
  25.  
  26. public static int capicuo(Integer a) {
  27. String st = a.toString();
  28. switch (st.length()) {
  29. case 1:
  30. st = "000" + st;
  31. break;
  32. case 2:
  33. st = "00" + st;
  34. break;
  35. case 3:
  36. st = "0" + st;
  37. break;
  38. }
  39. st = ""+st.charAt(3)+st.charAt(2)+st.charAt(1)+st.charAt(0);
  40. return Integer.parseInt(st);
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement