Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
#include <iostream>
using namespace std;
int main(void) {
int n,x;
cin >> n >> x;
int ans;
if (x-1 < n-x){
ans = x-1;
ans = n-x;
cout << ans << endl;
return 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment