CF 1136B Nastya Is Playing Computer Games

题目链接:codeforces.com/problemset/problem/1136/B

题目分析

    首先,读完题目,看了是个B题,嗯嗯......

    果断找规律,然后交了一波,居然过了!!!

代码区

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include <vector>
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int Max = 5e2 + 10;
const int mod = 1e9 + 7;

int main()
{
	int n, k;
	while (scanf("%d%d", &n, &k) != EOF)
	{
		int a = min(abs(k - 1), abs(n - k));
		printf("%d\n", 3 * n +  a);
	}
	return 0;
}

 

posted @ 2019-03-29 21:43  winter-bamboo  阅读(252)  评论(0编辑  收藏  举报