Guest User

Untitled

a guest
Sep 16th, 2021
47
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Scanner;
  2.  
  3. public class Exam {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. String input = scanner.nextLine();
  8. int sum1 = 1;
  9. int sum2 = 0;
  10. int result = 0;
  11. boolean isTheSame = Integer.parseInt(String.valueOf(input.charAt(1))) == Integer.parseInt(String.valueOf(input.charAt(2)));
  12.  
  13. for(int i = input.length() - 1; i >= 0;i--){
  14.  
  15. if(i == 0){
  16. sum1 += Integer.parseInt(String.valueOf(input.charAt(0)));
  17. break;
  18. }
  19. sum1 *= Integer.parseInt(String.valueOf(input.charAt(i)));
  20.  
  21. if(isTheSame){
  22. sum2 = sum2 + 2;
  23. break;
  24. }
  25.  
  26. }
  27. result = sum1 + sum2;
  28. System.out.println(result);
  29.  
  30. }
  31. }
RAW Paste Data