Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drawing book hacker rank soluion java8 #246

Open
Saurabhofficial7 opened this issue Sep 24, 2019 · 0 comments
Open

Drawing book hacker rank soluion java8 #246

Saurabhofficial7 opened this issue Sep 24, 2019 · 0 comments

Comments

@Saurabhofficial7
Copy link

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));
}

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant