美文网首页
CodeFoeces-996A

CodeFoeces-996A

作者: ss5smi | 来源:发表于2018-07-13 20:26 被阅读0次

    题目

    原题链接:A. Hit the Lottery

    题意

    有1,5,10,20,100五种面值的纸币,问所给的金额最少几张就能兑换。

    代码

    #include<bits/stdc++.h>
    using namespace std;
    int main() {
        int n,ans=0,s[5]={1,5,10,20,100};
        cin>>n;
        for(int i=4;i>=0;i--){
            if(n/s[i]>0){
                ans+=n/s[i];
                n-=(n/s[i]*s[i]);
            }
        }
        printf("%d\n",ans);
        return 0;
    }
    

    相关文章

      网友评论

          本文标题:CodeFoeces-996A

          本文链接:https://www.haomeiwen.com/subject/tqpspftx.html