zoukankan      html  css  js  c++  java
  • HDU-2021

    发工资咯:)

    Problem Description
    作为杭电的老师,最盼望的日子就是每月的8号了,因为这一天是发工资的日子,养家糊口就靠它了,呵呵
    但是对于学校财务处的工作人员来说,这一天则是很忙碌的一天,财务处的小胡老师最近就在考虑一个问题:如果每个老师的工资额都知道,最少需要准备多少张人民币,才能在给每位老师发工资的时候都不用老师找零呢?
    这里假设老师的工资都是正整数,单位元,人民币一共有100元、50元、10元、5元、2元和1元六种。
     
    Input
    输入数据包含多个测试实例,每个测试实例的第一行是一个整数n(n<100),表示老师的人数,然后是n个老师的工资。
    n=0表示输入的结束,不做处理。
     
    Output
    对于每个测试实例输出一个整数x,表示至少需要准备的人民币张数。每个输出占一行。
     
    Sample Input
    3
    1 2 3
    0
     
    Sample Output
    4
     
     1 #include<stdio.h>
     2 #include<stdlib.h>
     3 #include<math.h>
     4 #include<string.h>
     5 int main()
     6 {
     7     int n;
     8     int i100,i10,i5,i2,i1,i50;
     9     int k,t;
    10     int sum;
    11     while (1)
    12     {
    13         scanf("%d",&n);
    14         if (!n) break;
    15         sum=0;
    16         while (n--)
    17         {
    18             t=0;
    19             scanf("%d",&k);
    20             while (k!=0)
    21             {
    22                 if (k/100>0)
    23                 {
    24                     t=k/100;
    25                     k-=t*100;
    26                     sum+=t;
    27                 }
    28                 if (k/50>0)
    29                 {
    30                     t=k/50;
    31                     k-=t*50;
    32                     sum+=t;
    33                 }
    34                 if (k/10>0)
    35                 {
    36                     t=k/10;
    37                     k-=t*10;
    38                     sum+=t;
    39                 }
    40                 if (k/5>0)
    41                 {
    42                     t=k/5;
    43                     k-=t*5;
    44                     sum+=t;
    45                 }
    46                 if (k/2>0)
    47                 {
    48                     t=k/2;
    49                     k-=t*2;
    50                     sum+=t;
    51                 }
    52                 if (k>0)
    53                 {
    54                     t=k;
    55                     k-=t;
    56                     sum+=t;
    57                 }
    58             }
    59         }
    60         printf("%d
    ",sum);
    61     }
    62     return 0;
    63 }
  • 相关阅读:
    UI5 Databind
    the meaning of myconputer environment path
    Linux查看日志常用命令
    fw: IP bonding in Linux.
    FW:expect tcl install
    install ET underlinux
    转expect 文一篇。
    linux 集萃
    try expect and autoexpect
    linux 压缩种类
  • 原文地址:https://www.cnblogs.com/leiyuxiang/p/3493314.html
Copyright © 2011-2022 走看看