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…
题意:有N堆石子,每堆有s[i]个,Alice和Bob两人轮流取石子,可以从一堆中取任意多的石子,也可以把一堆石子分成两小堆 Alice先取,问谁能获胜 思路:首先观察这道题的数据范围  1 ≤ N ≤ 10^6, 1 ≤ [Si] ≤ 2^31 - 1,很明显数据量太大,所以只能通过打表找规律 打表后发现,如果x%4==0 sg[x]=x-1 ;如果 x%4==3 sg[x]=x+1;如果 其他情况 sg[x]=x; 代码: 打表代码: #include <iostream> #includ…
题目链接 Description 桌子上有2n 堆石子,编号为1..2n.将第2k-1 堆与第2k 堆(1 ≤ k ≤ n)为同一组.第i堆的石子个数用一个正整数Si表示.一次分割操作指的是,从桌子上任取一堆石子,将其移走.然后分割它同一组的另一堆石子,从中取出若干个石子放在被移走的位置,组成新的一堆.操作完成后,所有堆的石子数必须保证大于0.显然,被分割的一堆的石子数至少要为2.两个人轮流进行分割操作.如果轮到某人进行操作时,所有堆的石子数均为1,则此时没有石子可以操作,判此人输掉比赛. 例如…
Alice and Bob are playing a stone game. Initially there are n piles of stones and each pile contains some stone. Alice stars the game and they alternate moves. In each move, a player has to select any pile and should remove at least one and no more t…
打表找规律即可. 1,1,2,2,2,3,3,3,3,4,4,4,4,4... 注意打表的时候,sg值不只与剩下的石子数有关,也和之前取走的方案有关. //#include<cstdio> //#include<set> //#include<cstring> //using namespace std; //bool vis[16]; //int n,SG[16][1<<16]; //int sg(int x,int moved) //{ // if(SG…
以后这种题还是不能空想,必须打个表看看,规律还是比较好找的……具体是啥看代码.用SG函数暴力的部分就不放了. #include<cstdio> using namespace std; int T,N,B,n; int main() { freopen("powers.in","r",stdin); scanf("%d",&T); for(;T;--T) { int ans=0; scanf("%d",&a…
A Simple Nim 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5795 Description Two players take turns picking candies from n heaps,the player who picks the last one will win the game.On each turn they can pick any number of candies which come from the…
Nim or not Nim? Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 858    Accepted Submission(s): 412 Problem Description Nim is a two-player mathematic game of strategy in which players take turns…
Nim or not Nim? Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1056    Accepted Submission(s): 523 Problem Description Nim is a two-player mathematic game of strategy in which players take turn…
#include<bits/stdc++.h>using namespace std;int sg[1007];int main(){ int t; cin>>t; while(t--){ int n,k; cin>>n>>k; if(k%3==0){ n%=(k+1); if(n==k||n%3) cout<<"Alice"<<"\n"; else cout<<"Bob&…