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)