Previous Questions matrix Flip coin (Blue Bridge Cup)

Source: Internet
Author: User
Previous questions matrix Flip coin time limit: 1.0s memory limit: 256.0MB
Problem description Xiao Ming first put the coin into a matrix of n rows M column.

Xiao Ming then performed a Q operation on each coin separately.

The definition of the Q operation for the coin in row y of line x: Turn all the coins in line i*x, section j*y.

Where I and J are arbitrary to make the operation feasible positive integer, line number and column number are starting from 1.

When Xiaoming performed a Q operation on all the coins, he found a miracle-all the coins were facing upwards.

Xiaoming wanted to know how many coins were on the opposite side of the coin at the beginning. So he sought help from his good friend, Little M.

The clever little m tells Xiaoming that it takes only one more Q operation for all the coins to return to the very first state. However, Xiao Ming is very lazy and unwilling to do it. So Xiaoming wants you to give him a better way. Help him figure out the answer. Input format input data contains one row, two positive integers n m, meaning see topic description. The output format outputs a positive integer that indicates how many coins are on the opposite side of the beginning. Sample Input 2 3 sample Output 1 data size and convention for 10% of data, N, M <= 10^3;
For 20% of data, N, M <= 10^7;
For 40% of data, N, M <= 10^15;
For 10% of data, N, M <= 10^1000 (10 of 1000). The recent state has not been adjusted well .... Take a break, please.

Previous Questions matrix Flip coin (Blue Bridge Cup)

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.