Problem D
Time Limit : 3000/1000ms (Java/Other) Memory Limit : 65535/32768K (Java/Other)
Total Submission(s) : 945 Accepted Submission(s) : 121
Font: Times New Roman | Verdana | Georgia
Font Size: ← →
Problem Description
阿黄的银行最近有发行了一种新面额的钞票面值为4,所以现在黄有5中
面额的钞票,分别是20,10,5,4,1。但是不变的是他的小气(同题2),现在
又有很多人来取钱,黄又不开心了,请你算出每个来取钱的人黄应该给他
多少张钞票。
面额的钞票,分别是20,10,5,4,1。但是不变的是他的小气(同题2),现在
又有很多人来取钱,黄又不开心了,请你算出每个来取钱的人黄应该给他
多少张钞票。
Input
多组样例,每组给出一个n,n为要取出的金额。(n<=10^6&&组数小于等于10^6)
Output
每组样例输出一个答案(钞票数)。
Sample Input
1
Sample Output
1
Author
这个题目和1002不是一个画风的惹QAQ
同学说是dp惹,我没想到,不过我知道,把钱对20取余,看余数是多少(反正余数不会大于20的),分情况再加上还要的钞票数
#include<stdio.h>
//#include<bits/stdc++.h>
#include<string.h>
#include<iostream>
#include<math.h>
#include<sstream>
#include<set>
#include<queue>
#include<map>
#include<vector>
#include<algorithm>
#include<limits.h>
#define inf 0x3fffffff
#define INF 0x3f3f3f3f
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define ULL unsigned long long
using namespace std;
int main()
{
int n;
int a;
int sum;
while(scanf("%d",&n)!=EOF)
{
sum=0;
/* int b=1+5;
int c=4+4;
int d=5+4;
int e=10+4;
int h=10+1;//取2的
int b1=3+4;
int c1=10+2;
int d1=10+5+1;
int e1=19;
int r1=18;
int t1=13;//取3的
int sum=0;*/
a=n%20;
sum+=n/20;
if(a<=3)
{
sum+=a;
}
else if(a==1||a==4||a==5||a==10)
{
sum+=1;
}
else if(a==6||a==6||a==8||a==9||a==11||a==14||a==15)
{
sum+=2;
}
else if(a==7||a==12||a==13||a==16||a==18||a==19)
{
sum+=3;
}
else if(a==3||a==17)
{
sum+=4;
}
printf("%d
", sum);
}
return 0;
}