Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main(){
- int n, p;
- cin >> n >> p;
- if((p-1)<(n-p)) {
- if(p%2 != 0) cout<<(p-1)/2;
- else cout<<p/2;
- }
- else {
- if(n%2 != 0){
- if(p%2 == 0) cout << (n-p-1)/2;
- else cout<<(n-p+1)/2;
- }
- else{
- if(p%2 == 0) cout << (n-p)/2;
- else cout<<(n-p+1)/2;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement