UVA 1482 - Playing With Stones 题目链接 题意:给定n堆石头,每次选一堆取至少一个.不超过一半的石子,最后不能取的输,问是否先手必胜 思路:数值非常大.无法直接递推sg函数.打出前30项的sg函数找规律 代码: #include <stdio.h> #include <string.h> int t, n; long long num; long long SG(long long x) { return x % 2 == 0 ? x : SG(x /…
C - Playing With Stones Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %llu Submit Status Practice UVALive 5059 Description You and your friend are playing a game in which you and your friend take turns removing stones from piles.…
Fibonacci again and again Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 6253 Accepted Submission(s): 2603 Problem Description 不论什么一个大学生对菲波那契数列(Fibonacci numbers)应该都不会陌生,它是这样定义的: F(1)=1; F(…
Code: #include<cstdio> #include<algorithm> using namespace std; typedef long long ll; ll SG(ll i){ return i % 2 ==0 ? i / 2 : SG(i/2); } ll arr[100000]; int main(){ //freopen("input.in","r",stdin); int T; scanf("%d&quo…
A Simple Game Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/65535 K (Java/Others)Total Submission(s): 1487 Accepted Submission(s): 939 Problem Description Agrael likes play a simple game with his friend Animal during the classes. I…
S-Nim Problem Description Arthur and his sister Caroll have been playing a game called Nim for some time now. Nim is played as follows: The starting position has a number of heaps, all containing some, not necessarily equal, number of beads. The pl…
描述 Bessie is playing a number game against Farmer John, and she wants you to help her achieve victory. Game i starts with an integer N_i (1 <= N_i <= 1,000,000). Bessie goes first, and then the two players alternate turns. On each turn, a player can…
题意:nim游戏.加上限制每次不得取走超过当前堆一半的石子 1 ≤ N ≤ 100,1 ≤ ai ≤ 2 ∗ 1018 分析:由于ai过大.所以我们采用SG函数递推找规律. (详见代码) #include<cstdio> using namespace std; typedef long long ll; int T,n;ll x,S; ll GetSG(ll x){ ?GetSG(x>>):x>>; } int main(){ for(scanf("%d&q…
A Multiplication Game Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 3832 Accepted Submission(s): 2183 Problem Description Stan and Ollie play the game of multiplication by multiplying an in…
Fibonacci again and again Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 8380 Accepted Submission(s): 3462 Problem Description 任何一个大学生对菲波那契数列(Fibonacci numbers)应该都不会陌生,它是这样定义的:F(1)=1;F(2)=2;…
Boxes and Stones Paul and Carole like to play a game with S stones and B boxes numbered from 1 to B. Beforebeginning the game they arbitrarily distribute the S stones among the boxes from 1 to B - 1, leavingbox B empty. The game then proceeds by roun…
Problem Description 对于四川同胞遭受的灾难,全国人民纷纷伸出援助之手,几乎每个省市都派出了大量的救援人员,这其中包括抢险救灾的武警部队,治疗和防疫的医护人员,以及进行心理疏导的心理学专家.根据要求,我校也有一个奔赴灾区救灾的名额,由于广大师生报名踊跃,学校不得不进行选拔来决定最后的人选.经过多轮的考核,形势逐渐明朗,最后的名额将在"林队"和"徐队"之间产生.但是很巧合,2个人的简历几乎一模一样,这让主持选拔的8600很是为难.无奈,他决定通过捐款…
Mine Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 51 Accepted Submission(s): 6 Problem Description Have you ever played a game in Windows: Mine?This game is played on a n*m board, just lik…