最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

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

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

分享到微博請遵守國家法律
闸北区| 通化市| 屯留县| 工布江达县| 张北县| 河北省| 定陶县| 会宁县| 临清市| 闽侯县| 兴化市| 正安县| 广灵县| 从化市| 科技| 昌都县| 治多县| 子长县| SHOW| 大名县| 天台县| 双鸭山市| 和政县| 东乡族自治县| 濮阳县| 普宁市| 方城县| 乐昌市| 兴城市| 清丰县| 绥江县| 安岳县| 班玛县| 加查县| 长兴县| 灵武市| 紫云| 青河县| 东乌珠穆沁旗| 夏邑县| 巴林右旗|