[ZJOI2009]函数

恶心啊,居然找规律。

/**
 * Problem:function
 * Author:Shun Yao
 * Time:2103.5.31
 * Result:Accepted
 */

#include <cstdio>

long min(long x, long y) {
	return x < y ? x : y;
}

int main() {
	long n, k;
	freopen("function.in", "r", stdin);
	freopen("function.out", "w", stdout);
	scanf("%ld%ld", &n, &k);
	if (n == 1)
		putchar('1');
	else
		printf("%ld", min(k, (n - k + 1)) << 1);
	fclose(stdin);
	fclose(stdout);
	return 0;
}

 

posted @ 2013-06-03 15:07  hsuppr  阅读(224)  评论(0编辑  收藏  举报