hdu3537(Turning Turtles)

这个只要明确一个硬币作为一个状态求sg值就好了,然后是对一个硬币的sg打表找规律。。

相当不好找。。。2倍关系加上个位数的分类讨论。。

 

 

/**
 *        ┏┓    ┏┓
 *        ┏┛┗━━━━━━━┛┗━━━┓
 *        ┃       ┃  
 *        ┃   ━    ┃
 *        ┃ >   < ┃
 *        ┃       ┃
 *        ┃... ⌒ ...  ┃
 *        ┃       ┃
 *        ┗━┓   ┏━┛
 *          ┃   ┃ Code is far away from bug with the animal protecting          
 *          ┃   ┃   神兽保佑,代码无bug
 *          ┃   ┃           
 *          ┃   ┃        
 *          ┃   ┃
 *          ┃   ┃           
 *          ┃   ┗━━━┓
 *          ┃       ┣┓
 *          ┃       ┏┛
 *          ┗┓┓┏━┳┓┏┛
 *           ┃┫┫ ┃┫┫
 *           ┗┻┛ ┗┻┛
 */
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<queue>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<bitset>
#define inc(i,l,r) for(int i=l;i<=r;i++)
#define dec(i,l,r) for(int i=l;i>=r;i--)
#define link(x) for(edge *j=h[x];j;j=j->next)
#define mem(a) memset(a,0,sizeof(a))
#define ll long long
#define eps 1e-12
#define succ(x) (1LL<<(x))
#define lowbit(x) (x&(-x))
#define sqr(x) ((x)*(x))
#define mid ((x+y)>>1)
#define NM 100005
#define nm 2005
#define pi 3.1415926535897931
const int inf=100007;
using namespace std;
ll read(){
    ll x=0,f=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
    while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
    return f*x;
}



int n,d[NM],a[NM],s,b[NM],tot;
bool v[NM];

void out(int x){
    for(tot=0;x;x>>=1)b[++tot]=x&1;
    dec(i,tot,1)printf("%d",b[i]);
}



int sg(int x){
    if(x==0)return 1;
    for(tot=0;x;x>>=1)b[++tot]=x&1;
    int k=0,s=2;
    dec(i,tot-1,1){
	s<<=1;
	if(k%2==0){
	    if(b[i])k++,s+=3;
	}else{
	    if(b[i])k++;else s--;
	}
    }
    return s;
}


void init(){
    n=100;
    inc(i,0,n){
	mem(v);v[0]=true;
	inc(j,0,i-1)v[d[j]]=true;
	inc(j,0,i-1)inc(k,j+1,i-1)v[d[k]^d[j]]=true;
	inc(j,0,10000)if(!v[j]){d[i]=j;break;}
    }
    inc(i,0,n)out(i),printf(":%d %d\n",d[i],sg(i));
}

void solve(){
    while(~scanf("%d",&n)){
	s=0;
	inc(i,1,n)a[i]=read();
	sort(a+1,a+1+n);
	n=unique(a+1,a+1+n)-a-1;
	inc(i,1,n)s^=sg(a[i]);
	puts(s?"No":"Yes");
    }
}

int main(){
    //init();
    solve();
    return 0;
}

 

 

 

 

Daizhenyang's Coin

Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1077    Accepted Submission(s): 516


 

Problem Description

We know that Daizhenyang is chasing a girlfriend. As we all know, whenever you chase a beautiful girl, there'll always be an opponent, or a rival. In order to take one step ahead in this chasing process, Daizhenyang decided to prove to the girl that he's better and more intelligent than any other chaser. So he arranged a simple game: Coin Flip Game. He invited the girl to be the judge.
In this game, n coins are set in a row, where n is smaller than 10^8. They took turns to flip coins, to flip one coin from head-up to tail-up or the other way around. Each turn, one can choose 1, 2 or 3 coins to flip, but the rightmost selected must be head-up before flipping operation. If one cannot make such a flip, he lost.
As we all know, Daizhenyang is a very smart guy (He's famous for his 26 problems and Graph Theory Unified Theory-Network Flow does it all ). So he will always choose the optimal strategy to win the game. And it's a very very bad news for all the competitors.
But the girl did not want to see that happen so easily, because she's not sure about her feelings towards him. So she wants to make Daizhenyang lose this game. She knows Daizhenyang will be the first to play the game. Your task is to help her determine whether her arrangement is a losable situation for Daizhenyang.
For simplicity, you are only told the position of head-up coins. And due to the girl's complicated emotions, the same coin may be described twice or more times. The other coins are tail-up, of course.
Coins are numbered from left to right, beginning with 0.

 

 

Input

Multiple test cases, for each test case, the first line contains only one integer n (0<=n<=100), representing the number of head-up coins. The second line has n integers a1, a2 … an (0<=ak<10^8) indicating the An-th coin is head up.

 

 

Output

Output a line for each test case, if it's a losable situation for Daizhenyang can, print "Yes", otherwise output "No" instead.

 

 

Sample Input

 

0 1 0 4 0 1 2 3

 

 

Sample Output

 

Yes No Yes

 

 

Source

2010 ACM-ICPC Multi-University Training Contest(11)——Host by BUPT

 

 

Recommend

zhouzeyong

 

 

Statistic | Submit | Discuss | Note

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值