20140715 「博弈 - 威佐夫博弈」 HDOJ 1527 取石子游戏

来源:互联网 发布:org.apache.tools 编辑:程序博客网 时间:2024/05/21 11:34

Online JudgeOnline ExerciseOnline TeachingOnline ContestsExercise AuthorF.A.Q
Hand In Hand
Online Acmers
Forum | Discuss
Statistical Charts

Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
STD Contests 
VIP Contests 
Virtual Contests 
    DIY | Web-DIY beta
Recent Contests
Author wilson1068
Mail Mail 0(0)
Control Panel Control Panel 
Sign Out Sign Out

7月22-8月21多校联合训练期间,会根据实际负载关闭部分模块,若有不便,请谅解~

取石子游戏

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 3434    Accepted Submission(s): 1721


Problem Description
有两堆石子,数量任意,可以不同。游戏开始由两个人轮流取石子。游戏规定,每次有两种不同的取法,一是可以在任意的一堆中取走任意多的石子;二是可以在两堆中同时取走相同数量的石子。最后把石子全部取完者为胜者。现在给出初始的两堆石子的数目,如果轮到你先取,假设双方都采取最好的策略,问最后你是胜者还是败者。
 

Input
输入包含若干行,表示若干种石子的初始情况,其中每一行包含两个非负整数a和b,表示两堆石子的数目,a和b都不大于1,000,000,000。
 

Output
输出对应也有若干行,每行包含一个数字1或0,如果最后你是胜者,则为1,反之,则为0。
 

Sample Input
2 18 44 7
 

Sample Output
010
 

Source
NOI
 

Recommend
LL   |   We have carefully selected several similar problems for you:  1404 1536 1517 1524 1729 
 

Statistic | Submit | Discuss | Note
Home | TopHangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2014 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.003844(s) query 5, Server time : 2014-07-15 17:50:06, Gzip enabledAdministration





博弈:威佐夫博弈 模板一份

题解嘛,有空再补。。。






#include <stdio.h>int main(){int a, b;while( ~scanf("%d%d", &a, &b) ){if( a>b ) {int tmp=a; a=b; b=tmp;}long k = b-a;printf("%d\n", !( a==(int)(1.618033989*k) ) );}return 0;}


0 0
原创粉丝点击