程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> C++ >> C++入門知識 >> Codeforces 549C. The Game Of Parity 博弈

Codeforces 549C. The Game Of Parity 博弈

編輯:C++入門知識

Codeforces 549C. The Game Of Parity 博弈


 

如果最後走的那個人奇偶兩堆裡都沒有取完,則這個人是必勝的,另一個人想要贏就一定要把某一堆取完

判斷k的奇偶性和最後一步是誰走,分類討論

 

C. The Game Of Parity time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output

There are n cities in Westeros. The i-th city is inhabited by ai people. Daenerys and Stannis play the following game: in one single move, a player chooses a certain town and burns it to the ground. Thus all its residents, sadly, die. Stannis starts the game. The game ends when Westeros has exactly k cities left.

The prophecy says that if the total number of surviving residents is even, then Daenerys wins: Stannis gets beheaded, and Daenerys rises on the Iron Throne. If the total number of surviving residents is odd, Stannis wins and everything goes in the completely opposite way.

Lord Petyr Baelish wants to know which candidates to the throne he should support, and therefore he wonders, which one of them has a winning strategy. Answer to this question of Lord Baelish and maybe you will become the next Lord of Harrenholl.

Input

The first line contains two positive space-separated integers, n and k (1?≤?k?≤?n?≤?2·105) — the initial number of cities in Westeros and the number of cities at which the game ends.

The second line contains n space-separated positive integers ai (1?≤?ai?≤?106), which represent the population of each city in Westeros.

Output

Print string "Daenerys" (without the quotes), if Daenerys wins and "Stannis" (without the quotes), if Stannis wins.

Sample test(s) input
3 1
1 2 1
output
Stannis
input
3 1
2 2 1
output
Daenerys
input
6 3
5 20 12 7 14 101
output
Stannis
Note

In the first sample Stannis will use his move to burn a city with two people and Daenerys will be forced to burn a city with one resident. The only survivor city will have one resident left, that is, the total sum is odd, and thus Stannis wins.

In the second sample, if Stannis burns a city with two people, Daenerys burns the city with one resident, or vice versa. In any case, the last remaining city will be inhabited by two people, that is, the total sum is even, and hence Daenerys wins.



 

 

 

/* ***********************************************
Author        :CKboss
Created Time  :2015年06月15日 星期一 20時55分59秒
File Name     :CF549C.cpp
************************************************ */

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include

using namespace std;

int n,k;
int even,odd;

string EVEN="Daenerys";
string ODD="Stannis";

int main()
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);

	scanf("%d%d",&n,&k);
	for(int i=0,x;i=odd)
			{
				puts(EVEN.c_str()); return 0;
			}
			else
			{
				puts(ODD.c_str()); return 0;
			}
		}
		else // D make last move
		{
			int other = max(0,doo-(odd-1)-1);
			if(soo+other>=even)
			{
				puts(ODD.c_str()); return 0;
			}
			else
			{
				puts(EVEN.c_str()); return 0;
			}

		}
	}
	else if(k%2==0)
	{
		/// S make last move
		if(m%2==1)
		{
			bool flag=false;
			int other = max(0,soo-(even-1)-1);
			if(doo+other>=odd) flag=true;
			other = max(0,soo-(odd-1)-1);
			if(doo+other>=even) flag=true;
			if(flag)
			{
				puts(EVEN.c_str()); return 0;
			}
			else
			{
				puts(ODD.c_str()); return 0;
			}

		}
		else // D make last move
		{
			puts(EVEN.c_str()); return 0;
		}
	}

    
    return 0;
}


 

 

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