码迷,mamicode.com
首页 > 其他好文 > 详细

hdu2021 11页水题

时间:2018-10-02 22:18:06      阅读:202      评论:0      收藏:0      [点我收藏+]

标签:pid   main   img   isp   iostream   ble   closed   int   open   

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2021
暴力出解,可能数多了就不行了
题解:
技术分享图片
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
using namespace std;

int a[6]={100,50,10,5,2,1};

int num(int x)
{
    int sum=0;
    for(int i = 0;i< 6;i++)
    {
        int t = x/a[i];
        sum+=t;
        x = x- t*a[i];
    }
    return sum;    
}
int main()
{
    int n,a;
    while(cin>>n)
    {
        if(n==0)
        break;
        int count = 0;
        for(int i = 0;i< n;i++)
        {
            cin>>a;
            count+=num(a);
        }
        cout<<count<<endl;
    }
    return 0;
 } 
View Code

 

hdu2021 11页水题

标签:pid   main   img   isp   iostream   ble   closed   int   open   

原文地址:https://www.cnblogs.com/lyqf/p/9737889.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!