POJ 2484-a Funny Game (symmetric game)

Source: Internet
Author: User

Topic Link: Click to open the link

Test instructions: N number of numbers 1-n around a ring, two people take turns, each time can only take the adjacent two or only one, can not take the loser.

Consider such a problem, if it is not a ring but a line, that is, from the 1-n into a row, so that the initiator just take the middle of the two or a composition of the number of equal (left and right symmetry), then the initiator can be invincible (simply speaking, regardless of which side the opponent takes, The initiator can win as long as it is taken in the same way on the other side.

But this problem is a ring, consider the special case, when the length of the ring is less than 3 when the initiator win (directly all take), but greater than or equal to 3, any one can break the ring as the line (chain), and then because the line when the initiator wins, so the answer is the initiator will be defeated.

#include <algorithm> #include <iostream> #include <cstring> #include <cstdlib> #include < string> #include <cctype> #include <vector> #include <cstdio> #include <cmath> #include < queue> #include <stack> #include <map> #include <set> #define MAXN 10000002#define _ll __int64# Define ll long long#define INF 0x3f3f3f3f#define Mod 10000007#define pp pair<int,int> #define ull unsigned long Longu Sing namespace Std;int n;int main () {while (scanf ("%d", &n) &&n) {        if (n<3) puts ("Alice"); else puts (" Bob ");} return 0;}


POJ 2484-a Funny Game (symmetric game)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.