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.

这道题属于博弈题,还是第一次做呢。。我看题解加代码,终于看明白了。。这题需分情况讨论,先读入n个数字,记录奇数的个数num1以及偶数的个数num2,第一种当n=k的时候,那么双方都不用破坏城市,所以就看总数的和是奇还是偶;第二种是如果num1<=(n-k)/2,也就是说一方能在自己走的步数中把奇数的个数都消灭掉,那么之后不管谁走,剩下的都是偶数了,总和一定是偶数,所以必定S胜利;第三种是如果num2<=(n-k)/2,这种情况比较难想,刚开始一直不清楚为什么某一方一定要先把偶数个数都消灭掉,难道先消灭几个奇数不行吗,后来想通了,因为不管是谁消灭掉所有偶数(可能是一个人消灭的,也有可能是两个人一起消灭的),其中k%2?S:D这一方有必胜法(仔细想想会明白的);最后一种是不管怎么消灭,最后剩下k个数的时候既有偶数又有奇数,那么这个时候最后一个走的人一定是胜利的,因为他可以看情况消灭偶数或奇数来得到偶数或奇数。

#include<iostream>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<vector>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<algorithm>
using namespace std;
int a[200006];
int main()
{
int n,m,k,i,j,num1,num2;
while(scanf("%d%d",&n,&k)!=EOF)
{
num1=num2=0;
for(i=1;i<=n;i++){
scanf("%d",&a[i]);
if(a[i]%2==1)num1++;
else num2++;
}
if(num1+num2==k){
if((num1+num2*2)%2==1){
printf("Stannis\n");continue;
}
else{
printf("Daenerys\n");continue;
}
}
if(num1<=(n-k)/2){
printf("Daenerys\n");continue;
}
if(num2<=(n-k)/2){
if(k%2==1){
printf("Stannis\n");continue;
}
else{
printf("Daenerys\n");continue;
}
}
if((n-k)%2==1){
printf("Stannis\n");continue;
}
else{
printf("Daenerys\n");continue;
}
}
return 0;
}

codeforces Looksery Cup 2015 C. The Game Of Parity的更多相关文章

  1. codeforces Looksery Cup 2015 H Degenerate Matrix

    The determinant of a matrix 2 × 2 is defined as follows: A matrix is called degenerate if its determ ...

  2. codeforces Looksery Cup 2015 D. Haar Features

    The first algorithm for detecting a face on the image working in realtime was developed by Paul Viol ...

  3. codeforces Looksery Cup 2015 H Degenerate Matrix 二分 注意浮点数陷阱

    #include <cstdio> #include <cstring> #include <algorithm> #include <string> ...

  4. Looksery Cup 2015 C. The Game Of Parity —— 博弈

    题目链接:http://codeforces.com/problemset/problem/549/C C. The Game Of Parity time limit per test 1 seco ...

  5. Looksery Cup 2015 A. Face Detection 水题

    A. Face Detection Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/549/pro ...

  6. Looksery Cup 2015 B. Looksery Party 暴力

    B. Looksery Party Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/549/pro ...

  7. Codeforces VK CUP 2015 D. Closest Equals(线段树+扫描线)

    题目链接:http://codeforces.com/contest/522/problem/D 题目大意:  给你一个长度为n的序列,然后有m次查询,每次查询输入一个区间[li,lj],对于每一个查 ...

  8. Looksery Cup 2015 D. Haar Features 暴力

    D. Haar Features Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/549/prob ...

  9. Looksery Cup 2015 H. Degenerate Matrix 数学

    H. Degenerate Matrix Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/549/ ...

随机推荐

  1. Core3.1 微信v3 JSAPI支付

    1.前言 "小魏呀,这个微信支付还要多久?","快了快了老板,就等着最后一步了...","搞快点哈,就等着上线呢","...... ...

  2. 二本学生拿到腾讯大厂offer的成长记录

    本人迈莫,是在20年以春招实习生的身份进入鹅厂,经过重重波折,最终成为鹅仔一份子.接下来我会以我亲生经历为例,分享一下普通大学的学生也是可以进去大厂,拭目以待!!! 初入大学 惨遭毒打 时间倒回到17 ...

  3. 配置Charles 设置手机代理并允许https请求

    前言: 在h5开发调试时,为实现手机app访问localhost地址,可以使用ip地址的方式,但一般公司app出于安全考虑,会限制只能访问其自有域名.因此,使用charles代理的方式 步骤 用手机代 ...

  4. Optimal asymmetric encryption padding 最优非对称加密填充(OAEP)

    SubtleCrypto.decrypt() - Web APIs | MDN https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypt ...

  5. (Oracle)误删oracle表结构恢复

    在操作数据库时,我们常常会不小心把表结构删除了.有时候建表很麻烦大到100多个字段,而又找不到当初的建表语句.其实这时候不用担心,oracle和咱们widows一样,他也有个回收站,只要你没有清除回收 ...

  6. <script>元素

    简介 向HTML页面中插入JavaScript的主要方法,就是使用'<'script'>'元素. 标签的位置 现代Web应用程序一般都把全部的JavaScript饮用放在'<'bod ...

  7. POJ1195 二维线段树

    Mobile phones POJ - 1195 Suppose that the fourth generation mobile phone base stations in the Tamper ...

  8. Opencart 后台getshell

    朋友实战中遇到的,帮忙看后台getshell. 修改日志文件,但是奈何找不到warning这类等级的错误,没办法控制写入的内容,通过sql报错能写入了,但是尖括号却会被实体,使用16进制一样会实体.. ...

  9. Eslint错误提示

    "Missing semicolon." : "缺少分号.","Use the function form of \"use strict\ ...

  10. Spring Cloud Config、Apollo、Nacos配置中心选型及对比

    Spring Cloud Config.Apollo.Nacos配置中心选型及对比 1.Nacos 1.1 Nacos主要提供以下四大功能 2.Spring Cloud Config 3.Apollo ...