2068. Game of Nuts

Time limit: 1.0 second
Memory limit: 64 MB
The war for Westeros is still in process, manpower and supplies are coming to an end and the winter is as near as never before. The game of thrones is unpredictable so Daenerys and Stannis decided to determine the true ruler of Seven Kingdoms playing more predictable and shorter game. For example, the game of nuts is the ideal candidate.
Rules of this game are quite simple. Players are given n heaps of nuts. There is an odd number of nuts in each heap. Players alternate turns. In each turn player chooses an arbitrary heap and divides it into three non-empty heaps so as there is again an odd number of nuts in each heap. The player who cannot make a move loses.
Daenerys has dragons so she moves first. Your task is to determine the winner assuming both Daenerys and Stannis play optimally. Please, do it and stop the war for Westeros!

Input

In the first line there is an odd integer n (1 ≤ n ≤ 777).
In the second line there are n integers separated by spaces. These are the amounts of nuts in each heap at the beginning of the game. It is guaranteed that each heap contains not less than one and not more than 54321 nuts and this amount is an odd number.

Output

Output "Daenerys" (without quotes) in case of Daenerys’ win. Otherwise output "Stannis".

Samples

input output
1
3
Daenerys
3
1 1 1
Stannis
5
777 313 465 99 1
Daenerys
Problem Author: Alexey Danilyuk
Problem Source: Ural Regional School Programming Contest 2015
Difficulty: 96
 
题意:有两个人,n堆石子,每次每人将石子分成三堆(不是平分,divided不是平分的意思,呜呜呜),每堆石子要求分的前后都为奇数,问最后谁胜利
分析:
可以打表SG函数找规律
其实想想,x个石子,(x为奇数)
x = 2k + 1
分成三堆
2k + 1 = (2k1 + 1) + (2k2 + 1) + (2k3 + 1)
    = 2(k1+k2+k3+1) + 1
所以当k>=1是才是可分的
注意到k1+k2+k3+1 = k这个形式,
总的来看,这些ki分来分区,只有它们大于1才是可分的,但是每分一次,k1+k2+k3的和会少一
说明这堆石子做多分k次
所以sigma(a[i] div 2),判断奇偶即可
 
 /**
Create By yzx - stupidboy
*/
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <ctime>
#include <iomanip>
using namespace std;
typedef long long LL;
typedef double DB;
#define MIT (2147483647)
#define INF (1000000001)
#define MLL (1000000000000000001LL)
#define sz(x) ((int) (x).size())
#define clr(x, y) memset(x, y, sizeof(x))
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define mk make_pair inline int getInt()
{
int ret = ;
char ch = ' ';
bool flag = ;
while(!(ch >= '' && ch <= ''))
{
if(ch == '-') flag ^= ;
ch = getchar();
}
while(ch >= '' && ch <= '')
{
ret = ret * + ch - '';
ch = getchar();
}
return flag ? -ret : ret;
} int n; inline void input()
{
cin >> n;
} inline void solve()
{
int x, ans = ;
while(n--)
{
cin >> x;
ans += x / ;
} if(ans & ) cout << "Daenerys" << endl;
else cout << "Stannis" << endl;
} int main()
{
ios::sync_with_stdio();
input();
solve();
return ;
}

最新文章

  1. 初识Azkaban
  2. sql 小操作
  3. 《Linux内核设计与实现》课本第五章学习笔记——20135203齐岳
  4. javascript 之Object内置对象
  5. Don&#39;t make me think 摘录与读后感
  6. C++ 虚函数畅谈
  7. MeetMe
  8. java 关于extends 和implement的区别
  9. web开发常用样式
  10. 小米4c刷机
  11. Java中获取路径的方法_自我分析
  12. 进军VR虚拟现实-先来全景智慧城市-有梦想的互联网创业者
  13. 201521123118《java程序与设计》第11周学习总结
  14. Object Detection / Human Action Recognition 项目
  15. python基础的学习
  16. python 多进程多线程的对比
  17. Unity3D加密保护解决方案
  18. [JZOJ5836] Sequence
  19. iperf测试网络带宽
  20. JavaScript怎样学

热门文章

  1. Genesis不能运行Perl编译后的脚本
  2. NPOI基本操作XLS
  3. 【转】C++多态性
  4. iosTest
  5. 第一个JAVA创建
  6. React之JSX入门
  7. JustSniffer
  8. 名词解释——Ext JS4
  9. AngularJS 之 Factory、Service、Provider
  10. [Tools] 使用XP远程登录Win8系统