五月天青色头像情侣网名,国产亚洲av片在线观看18女人,黑人巨茎大战俄罗斯美女,扒下她的小内裤打屁股

歡迎光臨散文網 會員登陸 & 注冊

CF 854A - Fraction

2023-06-28 14:54 作者:您是打尖兒還是住店呢  | 我要投稿

Petya is a big fan of mathematics, especially its part related to fractions. Recently he learned that a fraction? is called proper iff its numerator is smaller than its denominator (a?<?b) and that the fraction is called irreducible if its numerator and its denominator are coprime (they do not have positive common divisors except 1).


During his free time, Petya thinks about proper irreducible fractions and converts them to decimals using the calculator. One day he mistakenly pressed addition button (?+?) instead of division button (÷) and got sum of numerator and denominator that was equal to n instead of the expected decimal notation.


Petya wanted to restore the original fraction, but soon he realized that it might not be done uniquely. That's why he decided to determine maximum possible proper irreducible fraction? such that sum of its numerator and denominator equals n. Help Petya deal with this problem.

----------------------------------------------------

Petya 是數(shù)學的忠實粉絲,尤其是與分數(shù)相關的部分。 最近他了解到,如果一個分數(shù)的分子小于分母(a?<?b),則該分數(shù)被稱為真分數(shù);如果其分子和分母互質(除了 1 之外,它們沒有正公約數(shù)),則該分數(shù)被稱為不可約分數(shù)。


在空閑時間,佩蒂亞思考不可約分數(shù)并使用計算器將其轉換為小數(shù)。 有一天,他錯誤地按了加法按鈕(?+?)而不是除法按鈕(÷),得到的分子和分母之和等于n,而不是預期的小數(shù)符號。


彼佳想要恢復原來的分數(shù),但很快他意識到這可能不是唯一的方法。 這就是為什么他決定確定最大可能的真不可約分數(shù),使其分子和分母之和等于 n。 幫助 Petya 解決這個問題。

-----------------------------------------------

依次遍歷即可,主要是要判斷最大公約數(shù)等于1;

下面是代碼:


CF 854A - Fraction的評論 (共 條)

分享到微博請遵守國家法律
儋州市| 泗水县| 山东省| 普安县| 东兴市| 紫金县| 屯昌县| 武邑县| 海南省| 邮箱| 大田县| 沅江市| 进贤县| 绥滨县| 涪陵区| 习水县| 洛扎县| 定边县| 渭南市| 大理市| 黑水县| 龙门县| 当阳市| 泊头市| 东兰县| 开封市| 依兰县| 深泽县| 永泰县| 长兴县| 怀柔区| 界首市| 古交市| 海安县| 芦溪县| 无极县| 昌图县| 东丰县| 杭州市| 黄龙县| 临安市|