ural 2068. Game of Nuts

时间:2023-03-08 15:46:59
ural 2068. Game of Nuts

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 ;
}