UVa 10561 (SG函数 递推) Treblecross】的更多相关文章

如果已经有三个相邻的X,则先手已经输了. 如果有两个相邻的X或者两个X相隔一个.,那么先手一定胜. 除去上面两种情况,每个X周围两个格子不能再放X了,因为放完之后,对手下一轮再放一个就输了. 最后当“禁区”布满整行,不能再放X了,那个人就输了. 每放一个X,禁区会把它所在的线段“分割”开来,这若干个片段就可以看做若干个游戏的和. 设g(x)表示x个连续格子对应的SG函数值,递推来求g(x): g(x) = mex{ g(x-3), g(x-4), g(x-5), g(x-6) xor g(1),…
题目描述 定义一种有根二叉树\(T(n)\)如下: (1)\(T(1)\)是一条长度为\(p\)的链: (2)\(T(2)\)是一条长度为\(q\)的链: (3)\(T(i)\)是一棵二叉树,它的左子树是\(T(i-2)\),右子树是\(T(i-1)\). 现在给定\(p,q,n\),现在Alice和Bob在树\(T(n)\)上玩游戏,每人轮流从树上拿掉一棵子树,直到有一个玩家拿掉根结点所在的子树为止(那么该玩家输了).现在问先手在第一轮有多少种拿掉子树的方法,可以保证之后自己一定能赢.只用输出…
F - Again Stone Game Time Limit:2000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu Submit Status Description Alice and Bob are playing a stone game. Initially there are n piles of stones and each pile contains some stone. Alice stars the…
Problem H. Cups and Beans 2017.8.11 原题: There are N cups numbered 0 through N − 1. For each i(1 ≤ i ≤ N − 1), the cup i contains Ai beans,and this cup is labeled with an integer Ci.Two people will play the following game:• In each turn, the player ch…
链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=3185 题意: A.B两人赛马,最终名次有3种可能:并列第一:A第一B第二:B第一A第二.输入n(1≤n≤1000),求n人赛马时最终名次的可能性的个数除以10056的余数. 分析: 设答案为f(n).假设第一名有i个人,有C(n,i)种可能性,接下来有f(n-i)种可能性,因此答案…
一.题目 A lattice point (x, y) in the first quadrant (x and y are integers greater than or equal to 0), other than the origin, is visible from the origin if the line from (0, 0) to (x, y) does not pass through any other lattice point. For example, the p…
Problem C Treblecross Input: Standard Input Output: Standard Output Time Limit: 4 Seconds Treblecross is a two player game where the goal is to get three X in a row on a one-dimensional board. At the start of the game all cells in the board is empty.…
UVA 10288 - Coupons option=com_onlinejudge&Itemid=8&page=show_problem&category=482&problem=1229&mosmsg=Submission+received+with+ID+13896541" target="_blank" style="">题目链接 题意:n个张票,每张票取到概率等价,问连续取一定次数后,拥有全部的票的期…
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2370 一道递推的题. 这道题的递推方程很容易可以想到,是枚举加上哪一个数字,把方法数累加起来.这道题主要是要注意前缀0的问题,可以通过枚举第一个数字不是一的所有情况,然后最后询问大于6的时候就加一. 代码如下(JAVA): import java.math.BigInteger; impor…
 Burger  When Mr. and Mrs. Clinton's twin sons Ben and Bill had their tenth birthday, the party was held at the McDonald's restaurant at South Broadway 202, New York. There were 20 kids at the party, including Ben and Bill. Ronald McDonald had made 1…