Codeforces 549C. The Game Of Parity Game
If the last one is not completed in the two heap even, this one will win. If the other one wants to win, it will be necessary to win one heap.
Judge k's parity and who is taking the last step and discuss it by category
C. The Game Of Parity time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output
There areNCities in guest OS.I-Th city is inhabitedAIPeople. 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 operating OS has exactlyKCities left.
The prophecy says that if the total number of specified ving residents is even, then Daenerys wins: Stannis gets beheaded, and Daenerys rises on the Iron Throne. if the total number of parameter ving 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 shoshould 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,NAndK(1? ≤?K? ≤?N? ≤? 2. 105)-the initial number of cities in each OS and the number of cities at which the game ends.
The second line containsNSpace-separated positive integersAI(1? ≤?AI? ≤? 106), which represent the population of each city in guest OS.
Output
Print string "Daenerys" (without the quotes), if Daenerys wins and "Stannis" (without the quotes), if Stannis wins.
Sample test (s) input
3 11 2 1
Output
Stannis
Input
3 12 2 1
Output
Daenerys
Input
6 35 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 region vor 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: CKbossCreated Time:, Monday, June 15, 2015 File Name: CF549C. cpp *************************************** * *********/# 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 ", & 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 moveif (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 ;}