POJ 2484 A Funny Game G++

Problem Result Memory Time Language Code Length
2484 Accepted 704K 0MS G++ 250B
#include <iostream>
using namespace std;
//《 挑战程序设计竞赛 》书中例题 
int main()
{
	while(1)
	{
		int NUM;
		cin>>NUM;
		if(NUM==0)
		{
			break;
		}else if((NUM==1)||(NUM==2))
		{
			cout<<"Alice"<<endl;
		}else
		{
			cout<<"Bob"<<endl;
		} 
	}
	return 0;
}

n 枚硬币,排成一圈。Alice 和 Bob 轮流取 1 枚或连续(中间没有空位)的 2 枚。取走最后一枚的获胜,求获胜方。


发布了1118 篇原创文章 · 获赞 9 · 访问量 33万+

猜你喜欢

转载自blog.csdn.net/woniupengpeng/article/details/78173235