无码av一区二区三区无码,在线观看老湿视频福利,日韩经典三级片,成 人色 网 站 欧美大片在线观看

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

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的評論 (共 條)

分享到微博請遵守國家法律
同仁县| 五家渠市| 同心县| 乌苏市| 德格县| 交城县| 额尔古纳市| 汉阴县| 观塘区| 秦皇岛市| 丽水市| 隆尧县| 靖州| 隆子县| 泸水县| 廉江市| 宁武县| 左贡县| 丰顺县| 吉林省| 孟村| 南漳县| 偏关县| 黄山市| 清原| 东明县| 本溪| 平泉县| 清远市| 多伦县| 长垣县| 大荔县| 黄石市| 南投县| 肥东县| 南充市| 涞水县| 搜索| 沾化县| 攀枝花市| 怀来县|