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

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

CF 996A - Hit the Lottery

2023-06-24 09:35 作者:您是打尖兒還是住店呢  | 我要投稿

Allen has a LOT of money. He has n dollars in the bank. For security reasons, he wants to withdraw it in cash (we will not disclose the reasons here). The denominations for dollar bills are 1, 5, 10, 20, 100. What is the minimum number of bills Allen could receive after withdrawing his entire balance?

艾倫有很多錢。 他在銀行有 n 美元。 出于安全考慮,他想以現(xiàn)金的方式提?。ㄎ覀冞@里不會(huì)透露原因)。 美元鈔票的面額為 1、5、10、20、100。艾倫提取全部余額后最少可以收到多少?gòu)堚n票?

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

看來(lái)Allen的錢并不多啊。。。

其實(shí)就是取余,依次循環(huán)即可;;

下面是代碼:

import java.util.Scanner;


public class A996 {

? ? public static void main(String[] args) {

? ? ? ? Scanner sc=new Scanner(System.in);

? ? ? ? int n=sc.nextInt();

? ? ? ? sc.close();

? ? ? ? int cnt=0;

? ? ? ? int[]arr={100,20,10,5,1};

? ? ? ? int i=0;

? ? ? ? while(n>0&&i<5){

? ? ? ? ? ? cnt+=n/arr[i];

? ? ? ? ? ? n=n%arr[i];

? ? ? ? ? ? i++;

? ? ? ? }

? ? ? ? System.out.println(cnt);

? ? }

}


沒(méi)錯(cuò)完全是湊字?jǐn)?shù)的。不好意思。

CF 996A - Hit the Lottery的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國(guó)家法律
长垣县| 永新县| 涿州市| 新兴县| 砀山县| 连江县| 左权县| 乌什县| 兴安县| 福清市| 承德县| 富源县| 商丘市| 阿拉善盟| 乌苏市| 驻马店市| 五原县| 浪卡子县| 苍溪县| 新建县| 专栏| 神农架林区| 南开区| 东兴市| 浑源县| 汝城县| 交城县| 牙克石市| 万宁市| 故城县| 佛山市| 临潭县| 海林市| 株洲市| 江孜县| 阜平县| 盱眙县| 枣阳市| 若尔盖县| 昌都县| 布尔津县|