牛客网-100-美团-硬币兑换

硬币兑换

http://www.nowcoder.com/questionTerminal/4f900b1c941c45288dba06baa006907f

import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int[] coins=new int[]{1,2,5,10,20,50,100};
        int type=0;
        int cnt=0;
        for(int i=0;i<coins.length;i++){
            if(n>=coins[i]){
                type++;
                cnt++;
                n-=coins[i];
            }
        }
        cnt+=n;
        System.out.println(type+" "+cnt);
    }
}
全部评论

相关推荐

面向对象的火龙果很爱...:去吃一顿炸鸡就走
点赞 评论 收藏
分享
见见123:简历没有啥问题,是这个社会有问题。因为你刚毕业,没有工作经历,现在企业都不要没有工作经历的。社会病了。
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
05-28 12:15
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务