Game of Taking Stones

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 456    Accepted Submission(s): 174

Problem Description
Two people face two piles of stones and make a game. They take turns to take stones. As game rules, there are two different methods of taking stones: One scheme is that you can take any number of stones in any one pile while the alternative is to take the same amount of stones at the same time in two piles. In the end, the first person taking all the stones is winner.Now,giving the initial number of two stones, can you win this game if you are the first to take stones and both sides have taken the best strategy?
 
Input
Input contains multiple sets of test data.Each test data occupies one line,containing two non-negative integers a andb,representing the number of two stones.a and b are not more than 10^100.
 
Output
For each test data,output answer on one line.1 means you are the winner,otherwise output 0.
 
Sample Input
2 1
8 4
4 7
 
Sample Output
0
1
0
 
Source
 
Recommend
 
 
裸bash game,大数
唯一要注意的就是开方要精确到小数点后100位
JAVA大数,
 import java.math.*;
import java.util.Scanner; public class Main {//类名要用Main
public static void main(String[] args){ //BigDecimal gr = new BigDecimal(((Math.sqrt(5.0)) + 1) / 2);
BigDecimal gr = new BigDecimal("1.618033988749894848204586834365638117720309179805762862135448622705260462818902449707207204189391137");
//System.out.println("gr = " + gr);
BigDecimal a2, b2;
BigInteger a, b, t;
BigDecimal k;
BigInteger k2;
Scanner sc=new Scanner(System.in);
while (sc.hasNextBigInteger()) {
a=sc.nextBigInteger();
b=sc.nextBigInteger();
if (a.compareTo(b) > ) {
t = a;
a = b;
b = t;
}
a2 = new BigDecimal(a);
b2 = new BigDecimal(b); k = (b2.subtract(a2));
k = k.multiply(gr);
k2 = k.toBigInteger(); if (k2.compareTo(a) == ) {
System.out.println("");
} else {
System.out.println("");
}
} }
}

JAVA大数类的使用还不是很熟练。

 
 

hdu 5973 Game of Taking Stones(大数,bash game¥)的更多相关文章

  1. HDU 5973 Game of Taking Stones 威佐夫博弈+大数

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5973 Game of Taking Stones Time Limit: 2000/1000 MS ...

  2. HDU - 5973 Game of Taking Stones (威佐夫博弈 高精度)

    题目描述: Two people face two piles of stones and make a game. They take turns to take stones. As game r ...

  3. HDU 5973 Game of Taking Stones (威佐夫博弈+高精度)

    题意:给定两堆石子,每个人可以从任意一堆拿任意个,也可以从两堆中拿相同的数量,问谁赢. 析:直接运用威佐夫博弈,floor(abs(a, b) * (sqrt(5)+1)/2) == min(a, b ...

  4. HDU 5973 Aninteresting game 威佐夫博奕(Wythoff Game)

    HDU 5973:http://acm.hdu.edu.cn/showproblem.php?pid=5975 题意: 有两堆石子,每次可以从一堆石子中取任意个,或者从两堆石子中取相同个数的石子.两个 ...

  5. HDU 4006The kth great number(K大数 +小顶堆)

    The kth great number Time Limit:1000MS     Memory Limit:65768KB     64bit IO Format:%I64d & %I64 ...

  6. HDU 1250 Hat's Fibonacci(大数相加)

    传送门:http://acm.hdu.edu.cn/showproblem.php?pid=1250 Hat's Fibonacci Time Limit: 2000/1000 MS (Java/Ot ...

  7. HDOJ/HDU 1297 Children’s Queue(推导~大数)

    Problem Description There are many students in PHT School. One day, the headmaster whose name is Pig ...

  8. HDU 1023 Train Problem II (大数卡特兰数)

    Train Problem II Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  9. hdu 1226 bfs+余数判重+大数取余

    题目: 超级密码 Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total ...

随机推荐

  1. 面向对象 - 1.软件开发/2.异常处理/3.try...except的详细用法

    1.软件开发 软件的开发其实一整套规范,我们所学的只是其中的一小部分,一个完整的开发过程,需要明确每个阶段的任务,在保证一个阶段正确的前提下再进行下一个阶段的工作,称之为软件工程 面向对象的软件工程包 ...

  2. DOM 综合练习(二)

    // 需求一: 二级联动菜单 <html> <head> <style type="text/css"> select{ width:100px ...

  3. JMH 性能测试框架

    参考 1 Java 并发编程笔记:JMH 性能测试框架  http://blog.dyngr.com/blog/2016/10/29/introduction-of-jmh/ 2  Code Samp ...

  4. 对ASIHTTPRequest的封装

    版权声明:本文为博主原创文章.未经博主同意不得转载. https://blog.csdn.net/quanqinayng/article/details/37659751 .h文件  // // Ht ...

  5. Erlang正则解析操作文件

    -module(tool). %% ==================================================================== %% API functi ...

  6. 简明python教程五----数据结构

    python中有三种内建的数据结构:列表.元组和字典 list是处理一组有序项目的数据结构,即你可以在一个列表中存储一个序列的项目.在python中,每个项目之间用逗号分隔. 列表中的项目应该包括在方 ...

  7. Centos学习笔记1-基本部分

    1:查看系统的使用状态: 谁在线:who 网络连接状态:netstat  –a 后台执行程序:ps –aux 2:关机 关机:shutdown   或者 shutdown –h now 重启:rebo ...

  8. image_Magic图片处理功能

    :] 来自为知笔记(Wiz)

  9. form:checkboxes radiobutton select用法

    <form:checkboxes path="subjects" items="${requestScope.subjects}" element=&qu ...

  10. 网络管理常用命令(6/14) -netstat命令详解

    Netstat 命令用于显示各种网络相关信息,如网络连接,路由表,接口状态 (Interface Statistics),masquerade 连接,多播成员 (Multicast Membershi ...