Skip to content

Instantly share code, notes, and snippets.

@esthicodes
Created August 24, 2021 01:17
Show Gist options
  • Save esthicodes/592f9036e26448914419f202fff590c6 to your computer and use it in GitHub Desktop.
Save esthicodes/592f9036e26448914419f202fff590c6 to your computer and use it in GitHub Desktop.
#include <stdio.h>
int main()
{
int n,p,j=0,a[100000];
scanf("%d",&n);
scanf("%d",&p);
for (int i=0;i<=n;i++)
if (i%2==0)
{
j++;
a[i]=j;
a[i+1]=j;
}
if (a[p]-1<j-a[p]) printf("%d",a[p]-1);
else printf("%d",j-a[p]);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment