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.

Examples
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.

题目大意:

n个城市,每人轮流屠掉一个城市,最后剩下k个城市,如果剩下的k个城市的人数和是奇数,那么先手赢,否则后手赢。

思路:

如果后手能够有机会屠掉所有奇数城,那么先手必败。

如果有奇数城剩余,继续考虑如果要屠的城为奇数座,那么先手可以最后利用偶数城,调整当前奇数城的数量,必胜。

但是如果后手能够将偶数城全部干掉,那么最后就变成看剩下的k是奇数还是偶数了。

如果要杀偶数个城,那么后手可以做最后调整,如果先手杀不光偶数城,那么后手必胜,如果先手能杀光偶数城,

那么结果就看剩下的k是奇数还是偶数了。

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<queue>
using namespace std;
int n,k,a[];
int main()
{
scanf("%d%d",&n,&k);
int i,cnt=;
for (i=;i<=n;i++)
{
int x;
scanf("%d",&x);
if (x&) cnt++;
}
int num2=(n-k)>>;
int num1=(n-k+)>>;
bool fg=true;
if (cnt<=num2)
fg=false;
if (k%==&&n-cnt<=num2)
fg=false;
if ((n-k)%==)
{
if ((num1>=n-cnt&&k%)==false)
fg=false;
}
if (n==k)
fg=(cnt&)?true:false;
puts(fg?"Stannis":"Daenerys");
return ;
}

最新文章

  1. 父元素相对定位后,子元素在ie下被覆盖的问题!
  2. MVVM架构~Knockoutjs系列之text,value,attr,visible,with的数据绑定
  3. JSP网站开发基础总结《十二》
  4. jquery easy ui 1.3.4 Tree树形菜单(9)
  5. php文本里 php和html代码谁先执行谁啊
  6. sql openrowset
  7. 正则化,数据集扩增,Dropout
  8. T-SQL切割字符串方法小结
  9. jQuery 验证实例(shopnc二次开发)
  10. parseSdkContent failed 解决方案
  11. 利用 FormData 对象和 Spring MVC 配合可以实现Ajax文件上载功能
  12. DOM操作中,遍历动态集合的注意事项。ex: elem.children
  13. Windows Developer Day - MSIX and Advanced Installer
  14. nexus-2.14.2-01-bundle构建maven私服
  15. Exchange Server 内部版本号和发行日期汇总
  16. SVM探讨
  17. [20180926]共享池中的NETWORK BUFFER.txt
  18. U盘内容被病毒隐藏的解决办法(亲测可用)
  19. Leetcode 124 *
  20. Unicode与中文转换工具类方法(转)

热门文章

  1. java操作Excel、PDF文件
  2. codevs 2905 足球晋级
  3. postman使用--断言
  4. B6. Concurrent 内存模型与线程交互
  5. 智能指针unqiue_ptr
  6. openjudge-4017 爬楼梯
  7. html/css:简单网页
  8. Python_编程题集_002_菱形
  9. python测试工具
  10. Nginx安装及基本配置