[CodeForces] [638A] Home Numbers

Problem Description

Loading...

Problem Analysis

Find the pattern, and it’s a one-liner kill.

cpp
1
2
3
4
5
6
7
#include<stdio.h>
int main() {
	int n,a;
	while(scanf("%d %d",&n,&a)!=EOF)
		printf("%d\n",a&1?(a-1)/2+1:(n-a)/2+1);
	return 0;
}

Problem link:【CodeForces】[638A]Home Numbers

This post is licensed under CC BY-NC-SA 4.0. If it helped, or if you have anything to say, the comment box below is open.
Page views —
Unique visitors —

Loading...