HDU 4662--MU Puzzle

Source: Internet
Author: User

The source of this question is MU conjecture in the AI field. I also referred to the relevant materials during the competition, but in the end I barely introduced the rule.

Note the following attributes. First, how to change M in MI is always the first place. Second, because the conversion can only be performed between I and U, except the first one is M. If there are strings not U or I, the conversion will never be possible. Third, U can be regarded as three I, whether I is first converted to U and then converted to a certain number of I, and then converted to a certain number of U, therefore, you can use I as the general equivalence to exchange all the letters.

 

# Include <iostream> # include <cstring> # include <string> using namespace std; int main () {int testcase; cin> testcase; while (testcase --) {string p = "MI"; int counti = 1, countu = 0, counti2 = 0, countu2 = 0, cm = 0, pos = 0; string tar; cin> tar; for (int I = 0; I <tar. length (); I ++) {if (tar [I] = 'M') {cm ++;} if (tar [I] = 'I ') {counti2 ++;} if (tar [I] = 'U') {countu2 ++ ;}} if (cm = 1 & tar [0] = 'M' & (countu2*3 + counti2) % 2 = 0 & (countu2*3 + counti2 ) % 3! = 0) | (countu2*3 + counti2) = 1) {pos = 1;} else {pos = 0;} if (pos = 0) {cout <"No" <endl;} else if (pos = 1) cout <"Yes" <endl;} return 0 ;}

 

Related Article

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.