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

歡迎光臨散文網(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ó)家法律
庆城县| 汨罗市| 乐至县| 通化县| 贺州市| 伊宁县| 禄劝| 郁南县| 平塘县| 连南| 浦县| 杭州市| 镶黄旗| 伽师县| 梧州市| 疏附县| 巴林左旗| 岐山县| 福泉市| 三明市| 柳河县| 达孜县| 赣榆县| 吕梁市| 黔江区| 鄂托克前旗| 安岳县| 禄丰县| 宜兴市| 攀枝花市| 江油市| 西城区| 烟台市| 四子王旗| 内乡县| 岚皋县| 通辽市| 德兴市| 县级市| 湾仔区| 东光县|