1. 程式人生 > >HDU 1564 Play a game (找規律博弈)

HDU 1564 Play a game (找規律博弈)

Play a game

Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1030    Accepted Submission(s): 838


Problem Description New Year is Coming! 
ailyanlu is very happy today! and he is playing a chessboard game with 8600. 
The size of the chessboard is n*n. A stone is placed in a corner square. They play alternatively with 8600 having the first move. Each time, player is allowed to move the stone to an unvisited neighbor square horizontally or vertically. The one who can't make a move will lose the game. If both play perfectly, who will win the game? Input The input is a sequence of positive integers each in a separate line. 
The integers are between 1 and 10000, inclusive,(means 1 <= n <= 10000) indicating the size of the chessboard. The end of the input is indicated by a zero. Output Output the winner ("8600" or "ailyanlu") for each input line except the last zero. 
No other characters should be inserted in the output. Sample Input 2 0 Sample Output 8600 Author ailyanlu Source Recommend 8600

從一個n*n的角落出發,每次移動到相鄰的,而且沒有經過的格子上。誰不能操作了誰輸。

結論就是n為偶數,先手贏,奇數,後手贏。

可以看下圖

S表示起點。

如果n為偶數,那麼所有格子可以被2*1的磚塊覆蓋掉。

這樣先手每次都移動到當前1*2的另外一塊。先手必贏。

如果n為奇數。出了起始那個店,其餘點都可以被覆蓋。

所有後手贏

#include <string.h>
#include <stdio.h>
#include <algorithm>
#include <iostream>
using namespace std;
int main()
{
    int n;
    
while(scanf("%d",&n)==1 &&n) { if(n%2==0)printf("8600\n"); else printf("ailyanlu\n"); } return 0; }

相關推薦

題解報告:hdu 1564 Play a game規律博弈

正整數 lse CI character square placed eight 技術 分享 題目鏈接:http://acm.hdu.edu.cn/showproblem.php?pid=1564 Problem Description New Year is Coming

HDU 1564 Play a game 規律博弈

Play a game Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1030    Accepted Submission(s): 838 P

hdu 1564 Play a game 博弈 奇偶規律

Play a game Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2322 Acce

HDU 6267 Master of Random 規律

題意: 給你n(n<=1e5)個節點。第i個節點的父親是隨機的,範圍為0~i-1。 定義一棵樹的值為    其中val[i]為以i為根的子樹的所有點的權值之和。 給你a[i](i=1~n)(每個點的權值),求所有可能的樹的平均值。

HDU-4015:Mario and Mushrooms規律

Mario and Mushrooms Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65768/65768 K (Java/Othe

題解報告:hdu 1846 Brave Game巴什博弈

show 法則 個人 amp mes cout ret 每年 簡單題 題目鏈接:http://acm.hdu.edu.cn/showproblem.php?pid=1846 Problem Description 十年前讀大學的時候,中國每年都要從國外引進一些電影大片,其中

翻翻棋規律問題FZU Problem 2230 FZU Problem 2230

題目是這樣的: FZU Problem 2230 象棋翻翻棋(暗棋)中雙方在4*8的格子中交戰,有時候最後會只剩下帥和將。根據暗棋的規則,棋子只能上下左右移動,且相同的級別下,主動移動到地方棋子方將吃掉對方的棋子。將和帥為同一級別。然而勝負在只剩下帥和將的時候已定。

CodeForces - 255B Code Parsing 規律簡單

Little Vitaly loves different algorithms. Today he has invented a new algorithm just for you. Vitaly's algorithm works with string s, consist

hdu 1698 Just a Hook線段樹基礎

成段更新的線段樹,加入了延時標記............ 線段樹這種東西細節上的理解因人而異,還是要自己深入理解......慢慢來 #include <iostream> #include <algorithm> #include <cmat

歷屆試題 連號區間數 規律+列舉

小明這些天一直在思考這樣一個奇怪而有趣的問題: 在1~N的某個全排列中有多少個連號區間呢?這裡所說的連號區間的定義是: 如果區間[L, R] 裡的所有元素(即此排列的第L個到第R個元素)遞增排序後能得到一個長度為R-L+1的“連續”數列,則稱這個區間連號區間。 當N很小的時候,小明可以很快地算出答案

牛客國慶集訓派對Day5——L 數論之神規律/數論

題目大意: 終於活成了自己討厭的樣子。 這是她們都還沒長大的時候發生的故事。那個時候,栗子米也不需要為了所謂的愛情苦惱。 她們可以在夏日的午後,花大把的時間去研究生活中一些瑣碎而有趣的事情,比如數論。 有一天西柚柚問了栗子米一個題,她想知道中有多少不同的數,這些不同的數

zoj 3057 Beans Game 三維博弈

題目連結:zoj 3057 題意:給三堆石頭,每次可以任選一堆(或者兩堆)取任意石子,取走最後一個石子的獲勝。 參考連結:https://blog.csdn.net/David_Jett/article/details/47296567?utm_source=blogxgwz0 題解

“浪潮杯”第九屆山東省ACM大學生程式設計競賽重現賽 G game 尼姆博弈

題目描述 Alice and Bob are playing a stone game. There are n piles of stones. In each turn, a player can remove some stones from a pile (th

HDU 5793 A Boring Question (規律 : 快速冪+乘法逆元)

cnblogs and ott miss 逆元 找規律 -- for while A Boring Question Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Ot

HDU 1079 Calendar Game規律博弈

days == tps turn NPU november val cal and 題目鏈接:https://cn.vjudge.net/problem/HDU-1079 題目: Adam and Eve enter this year’s ACM Internation

HDU 1041 Computer Transformation規律加大數乘

esp ios ctype nsf printf stream ont tac tran 主要還是找規律,然後大數相乘 #include<stdio.h> #include<string.h> #include<math.h> #inc

HDU 3788——ZOJ問題規律

題目連結 從樣例中找到其規律 就是第一次出現z的之前字元的個數 ×第一次出現z和最後出現j之間的‘o’的個數(且不能為空)=最後出現j之後的字元個數Accepted;(同理zoj也適用) #include<iostream> #include<set> #incl

hdu 1271 整數對規律

Problem Description Gardon和小希玩了一個遊戲,Gardon隨便想了一個數A(首位不能為0),把它去掉一個數字以後得到另外一個數B,他把A和B的和N告訴了小希,讓小希猜想他原來想的數字。不過為了公平起見,如果小希回答的數雖然不是A,但同

HDU 1005 Number Sequence規律,思維

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

牛客暑假多校——A-Ternary String規律+尤拉降冪模板

題目描述 A ternary string is a sequence of digits, where each digit is either 0, 1, or 2. Chiaki has a ternary string s which can self-repr