G - Game of Nuts URAL - 2068

Description

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

 

Sample Input

1
3

Sample Output

 

Daenerys

Sample Input

3
1 1 1

Sample Output

Stannis

Sample Input

 

5
777 313 465 99 1

Sample Output

 

Daenerys

题解:有两个人,n堆石子,每次每人将石子分成三堆(不是平分),每堆石子要求分的前后都为奇数,问最后谁胜利?找规律,题目要求为奇数,所以,1false,3true,5false(1,1,3),7true(1,3,3),9false(3,3,3),11true(1,3,7)...,由此发现每隔4个数成真。

代码如下:

#include<cstdio>
#include<cmath>
#include<map>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
const int MAX = 1e5 + 10;
typedef long long LL;
int a[MAX];
int main()
{
    int t,flag=0;
    cin>>t;
    while(t--)
    {
        int a;
        cin>>a;
        if((a+1)%4==0)
            flag=!flag;
    }
    if(flag==1)
        cout<<"Daenerys"<<endl;
    else
        cout<<"Stannis"<<endl;
        return 0;
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值