题解 CF638A 【Home Numbers】

题意:
有n个房子,现在左边是 1 3 5 7 9 这样的

右边是 n n-2 n-4 n-6 … 2这样的

然后问你x房子离起点的距离是多少
题目分析:
大水题!大水题!分奇数偶数乱看一下就好了……

#include<bits/stdc++.h>
using namespace std;
int n,m;
int main(){
    cin>>n>>m;
    if(m%2==1)
        cout<<m/2+1<<endl;
    else
        cout<<(n+2-m)/2<<endl;
    return 0;
}
原文地址:https://www.cnblogs.com/Sworddust/p/11427888.html