Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package aer515;
- import java.util.Scanner;
- /**
- *
- * @author Usuario
- */
- public class AER515 {
- Scanner in;
- /**
- * @param args the command line arguments
- */
- public boolean caso() {
- int casos = Integer.parseInt(in.nextLine());
- if (casos == 0) {
- return false;
- }
- if(casos == 1){
- System.out.println(casos);
- }else if (casos % 2 == 0) {
- System.out.println(casos - 1);
- } else {
- int resultado;
- resultado = casos - (casos * 1) / 2;
- System.out.println(resultado);
- }
- return true;
- }
- public void run() {
- in = new Scanner(System.in);
- while (caso()) {
- }
- }
- public static void main(String[] args) {
- new AER515().run();
- // TODO code application logic here
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement