[Fafu 1292] Game Theory, combined games, and stone removal games

Source: Internet
Author: User

Http://acm.fafu.edu.cn/problem.php? Id = 1292

 

The prototype of this question is the stone removal game c introduced in this paper, "from perceptual knowledge to rational understanding-the process of solving a kind of Combat Games ".

 

    • Game C:

A and B face several stones, and the number of stones in each row can be determined at will. Example 2 shows the initial situation: n = 3 rows in total, where a1 = 7 in the first row, a2 = 3 in the second row, and A3 = 3 in the third row. The two take turns to take some stones according to the following rules. The rules of the game are as follows:

2 stones must be removed from a row in each step;

The two stones must be closely tied;

Who is the loser if no one can take the child according to the rule.

 

The following code is provided:

# Include <cstdio> # include <cstring> using namespace STD; int SG [101]; bool me [101]; void getsg () {for (INT I = 0; I <= 100; ++ I) {memset (Me, 1, sizeof (me); For (Int J = 0; j <= (I-2)> 1); ++ J) me [SG [J] ^ SG [i-2-j] = 0; For (Int J = 0; j <= 100; ++ J) {If (me [J]) {SG [I] = J; break ;}}} int main () {int N, A; getsg (); While (~ Scanf ("% d", & N) {int res = 0; For (INT I = 0; I <n; ++ I) {scanf ("% d ", & A); Res ^ = SG [a];} If (RES) puts ("gabo"); else puts ("Tang");} return 0 ;}

[Fafu 1292] Game Theory, combined games, and stone removal games

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.