首页 > 其他 > 详细

Arena of Greed CodeForces - 1425A

时间:2021-07-03 10:57:20      阅读:23      评论:0      收藏:0      [点我收藏+]

原题链接
考察:博弈论
完全给我WA麻了,没有特判4这个点,结果是一直WA.
思路:
??3种情况:

  1. n为奇数,只有一种取法
  2. n为偶数且n/2也为偶数,此时和奇数一样取
  3. n为偶数且n/2为奇数,直接取一半.

当n==4这个点一定要特判

Code

#include <iostream>
#include <cstring>
using namespace std;
typedef long long LL;
const int N = 10;
LL n;
int f[N];
int main()
{
	int T;
	scanf("%d",&T);
	while(T--)
	{
		scanf("%lld",&n);
		LL res =0,t = n;
		bool ok = 1;
		while(n)
		{
			if(n==4)
			{
				if(ok) res+=3;
				else res++;
				n = 0;
			}else if(n&1){
				if(ok) res++;
				n--;
			}else if(n/2%2!=0){
				if(ok) res+=n/2;
				n/=2;
			}else{
				if(ok) res++;
				n--;
			}
			ok = ok^1;
		}
		printf("%lld\n",res);
	}
	return 0;
}

Arena of Greed CodeForces - 1425A

原文:https://www.cnblogs.com/newblg/p/14965446.html

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