Advertisement
Guest User

Untitled

a guest
Jan 24th, 2020
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package aer515;
  7.  
  8. import java.util.Scanner;
  9.  
  10. /**
  11. *
  12. * @author Usuario
  13. */
  14. public class AER515 {
  15.  
  16. Scanner in;
  17.  
  18. /**
  19. * @param args the command line arguments
  20. */
  21. public boolean caso() {
  22. int casos = Integer.parseInt(in.nextLine());
  23.  
  24. if (casos == 0) {
  25. return false;
  26. }
  27. if(casos == 1){
  28. System.out.println(casos);
  29. }else if (casos % 2 == 0) {
  30. System.out.println(casos - 1);
  31. } else {
  32. int resultado;
  33. resultado = casos - (casos * 1) / 2;
  34.  
  35. System.out.println(resultado);
  36. }
  37.  
  38. return true;
  39. }
  40.  
  41. public void run() {
  42. in = new Scanner(System.in);
  43.  
  44. while (caso()) {
  45.  
  46. }
  47. }
  48.  
  49. public static void main(String[] args) {
  50. new AER515().run();
  51. // TODO code application logic here
  52. }
  53.  
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement