首页 > 其他 > 详细

【Henu ACM Round#17 A】Simple Game

时间:2018-01-27 14:42:04      阅读:205      评论:0      收藏:0      [点我收藏+]

【链接】 我是链接,点我呀:)
【题意】


在这里输入题意

【题解】


肯定是放在m-1或者m+1的。
(m-1是左边的点都离a最近,而m+1则是右边的点都离他最近。
看看哪个更好就行

【代码】

#include <bits/stdc++.h>
#define ll long long
using namespace std;

ll n,m;

int main()
{
    ios::sync_with_stdio(0),cin.tie(0);
    #ifdef LOCAL_DEFINE
        freopen("rush.txt","r",stdin);
    #endif // LOCAL_DEFINE
    cin >> n >> m;
    if (m==1){
        return cout<<min(n,1LL*2)<<endl,0;
    }
    if (m==n){
        return cout<<max(1LL,n-1)<<endl,0;
    }
    int x = m-1,y = n-(m+1)+1;
    if (x>=y){
        cout <<m-1<<endl;
    }else{
        cout <<m+1<<endl;
    }
    return 0;
}

【Henu ACM Round#17 A】Simple Game

原文:https://www.cnblogs.com/AWCXV/p/8365499.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!