程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> C++ >> C++入門知識 >> POJ 1704-Georgia and Bob(階梯博弈)

POJ 1704-Georgia and Bob(階梯博弈)

編輯:C++入門知識

POJ 1704-Georgia and Bob(階梯博弈)


 

題意:n個棋子分布在x正半軸上,現在兩人輪流往左移動棋子,要求不能碰到其他棋子不能越界(不能移動到負半軸),最後不能移動者拜。

等價成階梯博弈,比如 2 5 7 9 ,如果5向左移動到3(移動了2格),那麼7可以移動的范圍就增大了兩格。

具體階梯博弈的了解看這裡:點擊打開鏈接

注意:最右邊的階梯相當於編號為1,而非最左邊的。(因為總是往左移動)還有,這題要排序。。。

 

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include
#include 
#define maxn 1002
#define _ll __int64
#define ll long long
#define INF 0x3f3f3f3f
#define Mod 10000007
#define pp pair
#define ull unsigned long long
using namespace std;
int n,a[maxn];
void solve()
{
	a[0]=0;int tem=0;
	for(int i=1;i<=n;i++){
		scanf(%d,a+i);
	}
	sort(a,a+n+1);
	for(int i=n;i>=1;i-=2){
		int d=a[i]-a[i-1]-1;
		tem^=d;
	}
	if(tem)puts(Georgia will win);
	else puts(Bob will win);
}
int main()
{

	int T;scanf(%d,&T);
	while(T--){
		scanf(%d,&n);
		solve();
	}
	return 0;
}


 

 

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved