URAL 1639 Chocolate 2 (game theory)

Source: Internet
Author: User
Tags time limit

1639. Chocolate 2
Time limit:1.0 Second
Memory limit:64 MB
Little boy was mad at Karlsson, who ate all the sweets in the flat and even went to the neighbours to eat their sweets too . Now Little boy's parents brought home a chocolate bar, and, sure enough, Karlsson are here already and wants to eat it. However, this time Little boy had firmly decided that isn't a single piece of chocolate would go to this glutton. Little boy wants to use Karlsson's addiction to the Games of chance and suggests playing the following game. A chocolate bar can be considered as a rectangle of square "units" arranged in  m rows and  n columns and separated by "lines". Players take alternate turns. At he turn, a player must take one piece of chocolate and split it into the along one of the. If a player can ' t make a legal move (which happens when all pieces of the chocolate consist of a single unit square), he loses , and the winner takes all the chocolate. But Karlsson is smart enough! He immediately understood who should make the first turn inOrder for Karlsson to win, assuming this players take optimal turns. Can you guess that?InputThe only line of the input contains space-separated integers m and n (1≤m, n≤50).OutputIf Karlsson should start the game in order to win, output "[: =[first]"; otherwise, output "[second]=:]".Samples

input Output
2 4
[: =[first]
1 3
[second]=:]




Test instructions: There is a row of n*m line of chocolate, two people take turns in the fold, the first one can not fold the man to lose.

Analysis: Simple game theory.



AC Code:

#include <cstdio>

int main () {
    int n, m;
    while (scanf ("%d%d", &n, &m) ==2) {
        if (n * M & 1) puts ("[second]=:]");
        else puts ("[: =[first]");
    }
    return 0;
}



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.