[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;

}

 

你可能感兴趣的:(函数)