HDU 1907 John (game)

Source: Internet
Author: User

Question

 

Refer to the blog: http://blog.csdn.net/akof1314/article/details/4447709

 

 

// 0 1-2 // 1 1-1 // 0 2-1 // 1 2-1 ///2 2-2 // 0 3-1 // 1 3 -1 // 2 3-1 // 3 3-2 // 0 4-1 // 1 4-1 // 2 4-1 // 3 4-1 // 4 4-2 // 0 5-1 // 1 5-1 // 2 5-1 // 3 5-1/* nheim game. For N-heap sugar, one case is that each heap is 1, so you will know who wins or who wins the heap number. If not all are 1, if these heaps are a strange situation, or they are non-singular situations, but non-singular situations can be converted to singular situations (for specific changes, refer to the previous article ). The classic nheim question is who gets the last one and who wins. This question is the last one. The second situation is analyzed below: 1. If the initial situation is a singular situation, the first attacker is the loser. 2. If the initial result is a non-singular situation, the winner is the winner. The number of non-singular and singular conversion times is relative. */# Include <stdio. h> # include <string. h> int main () {int t; scanf ("% d", & T); While (t --) {int N; int A [100]; scanf ("% d", & N); int sum = 0, K = 0; For (INT I = 0; I <n; I ++) {scanf ("% d", & A [I]); sum ^ = A [I]; // determines the singular situation like this? ^? If (A [I]! = 1) k = 1;} If (k = 0) {If (N % 2) printf ("Brother \ n "); else printf ("John \ n");} else {If (sum = 0) printf ("Brother \ n"); // you can determine a strange situation, 0 singular else printf ("John \ n"); // otherwise non-singular} return 0 ;}
View code

 

HDU 1907 John (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.