题解:CF1136B Nastya Is Playing Computer Games
zhuyucheng6046 · · 题解
这道题比较简单,可以这么做。
-
拿
n 个硬币,排水孔下各有一个。 -
从左边往右走或从右往左走要用
(n-1) 步。 -
想去某一边要走离边缘近的地方,
\min(n-k,k-1) 。 -
把所在地的石头往前扔,其余的到了那个点就往别的没有石头的井盖上扔
3+n-2 。
一共是
整理后是:
#include<bits/stdc++.h>//万能头文件
using namespace std;
int main()//主函数
{
int n,k;
cin>>n>>k;
cout<<3*n+min(n-k,k-1);//数学方法
return 0;//好习惯
}