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

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

CF 194A - Exams

2023-08-22 08:32 作者:您是打尖兒還是住店呢  | 我要投稿

One day the Codeforces round author sat exams. He had n exams and he needed to get an integer from 2 to 5 for each exam. He will have to re-sit each failed exam, i.e. the exam that gets mark 2.


The author would need to spend too much time and effort to make the sum of his marks strictly more than k. That could have spoilt the Codeforces round. On the other hand, if the sum of his marks is strictly less than k, the author's mum won't be pleased at all.


The Codeforces authors are very smart and they always get the mark they choose themselves. Also, the Codeforces authors just hate re-sitting exams.


Help the author and find the minimum number of exams he will have to re-sit if he passes the exams in the way that makes the sum of marks for all n exams equal exactly k.


Input

The single input line contains space-separated integers n and k (1?≤?n?≤?50, 1?≤?k?≤?250) — the number of exams and the required sum of marks.


It is guaranteed that there exists a way to pass n exams in the way that makes the sum of marks equal exactly k.


Output

Print the single number — the minimum number of exams that the author will get a 2 for, considering that the sum of marks for all exams must equal k.

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

有一天,Codeforces 回合的作者參加了考試。 他有n次考試,每次考試他都需要得到一個2到5之間的整數(shù)。 他必須重新參加每一次失敗的考試,即獲得 2 分的考試。


作者需要花費(fèi)太多的時間和精力才能使他的分?jǐn)?shù)總和嚴(yán)格超過 k。 這可能會破壞 Codeforces 回合。 另一方面,如果他的分?jǐn)?shù)總和嚴(yán)格小于 k,作者的媽媽根本不會高興。


Codeforces 的作者非常聰明,他們總是能得到自己選擇的分?jǐn)?shù)。 此外,Codeforces 作者只是討厭重新參加考試。


幫助作者求出如果他通過了考試,那么他需要重考的最少考試次數(shù),使得所有 n 次考試的分?jǐn)?shù)總和恰好等于 k。


輸入

單個輸入行包含空格分隔的整數(shù) n 和 k (1?≤?n?≤?50, 1?≤?k?≤?250) — 考試數(shù)量和所需的分?jǐn)?shù)總和。


保證存在一種通過n次考試的方法,使得分?jǐn)?shù)之和恰好等于k。


輸出

打印單個數(shù)字 — 考慮到所有考試的分?jǐn)?shù)總和必須等于 k,作者將獲得 2 分的最少考試次數(shù)。

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

求2個數(shù)的商,如果商為2 ,那么再看余數(shù),考試為2分的場數(shù)應(yīng)該是總場數(shù)-余數(shù)。

如果商大于2,那么一定是0;

下面是代碼:


CF 194A - Exams的評論 (共 條)

分享到微博請遵守國家法律
小金县| 且末县| 定结县| 泾源县| 兰西县| 微山县| 四川省| 应城市| 日照市| 永春县| 舟山市| 普兰店市| 巴林右旗| 博湖县| 衢州市| 陈巴尔虎旗| 兴和县| 临城县| 锦屏县| 马鞍山市| 漠河县| 于田县| 孝感市| 盈江县| 巩义市| 大兴区| 内江市| 姜堰市| 灵台县| 巴彦县| 雷山县| 霍林郭勒市| 全州县| 新疆| 万全县| 巫山县| 夹江县| 定州市| 曲阜市| 游戏| 福泉市|