CF 1764B - Doremy's Perfect Math Class
"Everybody! Doremy's Perfect Math Class is about to start! Come and do your best if you want to have as much IQ as me!" In today's math class, Doremy is teaching everyone subtraction. Now she gives you a quiz to prove that you are paying attention in class.
You are given a set S containing positive integers. You may perform the following operation some (possibly zero) number of times:
choose two integers x and y from the set S such that x>y and x?y
?is not in the set S.add x?y into the set S.
You need to tell Doremy the maximum possible number of integers in S if the operations are performed optimally. It can be proven that this number is finite.
-------------------------------------------------------------------------------
“大家!多蕾米完美數(shù)學(xué)課即將開始!如果你們想擁有和我一樣高的智商,就來加油吧!” 今天的數(shù)學(xué)課,Doremy正在教大家減法。 現(xiàn)在她給你一個(gè)測(cè)驗(yàn)來證明你在課堂上專心聽講。
給定一個(gè)包含正整數(shù)的集合 S。 您可以執(zhí)行以下操作幾次(可能為零):
從集合 S 中選擇兩個(gè)整數(shù) x 和 y,使得 x>y 且 x?y
? 不在集合 S 中。將 x?y 添加到集合 S 中。
如果運(yùn)算執(zhí)行最佳,您需要告訴 Doremy S 中可能存在的最大整數(shù)個(gè)數(shù)。 可以證明這個(gè)數(shù)是有限的。
---------------------------------------
其實(shí)就是求最大公約數(shù)的,因?yàn)榇_定了最大公約數(shù),那么最大值除以最大公約數(shù)就是所有可能的數(shù)的個(gè)數(shù);
只是最大公約數(shù)的代碼一開始搞錯(cuò)了,,,汗顏??;