Skip to content

Drawing book hacker rank soluion java8 #246

Description

@Saurabhofficial7

import java.io.;
import java.util.
;
import java.text.;
import java.math.
;
import java.util.regex.*;

public class Solution {

public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int n = in.nextInt();
    int p = in.nextInt();
    
    int beg = (p/2);
    int end = 0;
    if(n%2==1)
        end = (n-p)/2;
    else
        end = (int) Math.ceil((n-p)/2.0);
    
    System.out.println(Math.min(beg,end));
}

}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions