The 15th UESTC Programming Contest Preliminary C - C0ins cdoj1554
生活随笔
收集整理的這篇文章主要介紹了
The 15th UESTC Programming Contest Preliminary C - C0ins cdoj1554
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
地址:http://acm.uestc.edu.cn/#/problem/show/1554
題目:
C0ins
Time Limit: 3000/1000MS (Java/Others) ??? Memory Limit: 65535/65535KB (Java/Others)
There are infinite coins with values?1,2,5,101,2,5,10.
What's the minimum numbers of coins should be picked that?XX?and?YY?can be made change for?
Input
Two integers?XX?and?YY. (1≤X,Y≤1091≤X,Y≤109)
Output
The minimum numbers of coins should be picked.
Sample input and output
| 8 9 | 4 |
Hint
In sample, four coins?1,2,2,51,2,2,5?and?1,1,2,51,1,2,5?both can make change for?88?and?99.
Source
The 15th UESTC Programming Contest Preliminary ? #include<iostream> #include<algorithm> using namespace std;long long a,b,aa,bb,ans1,ans2,ans110,ans15,ans12,ans11,ans210,ans25,ans22,ans21;int check(int a,int b) {long long aa,bb,ans1,ans2,ans110,ans15,ans12,ans11,ans210,ans25,ans22,ans21;aa=bb=ans1=ans2=ans110=ans15=ans12=ans11=ans210=ans25=ans22=ans21=0;aa=a,bb=b;if(a<0||b<0)return 10000;ans110+=a/10;a%=10;ans15+=a/5;a%=5;ans12+=a/2;a%=2;ans11+=a;ans210+=b/10;b%=10;ans25+=b/5;b%=5;ans22+=b/2;b%=2;ans21+=b;ans1=max(ans110,ans210)+max(ans15,ans25)+max(ans12,ans22)+max(ans11,ans21);ans2=ans110+ans15+ans11+ans12;bb-=aa;ans2+=bb/10;bb%=10;ans2+=bb/5;bb%=5;ans2+=bb/2;bb%=2;ans2+=bb;return min(ans2,ans1); }int main() {cin>>a>>b;if(a>b)swap(a,b);cout<<min(check(a,b),check(a-6,b-14)+4);return 0; }?
轉載于:https://www.cnblogs.com/weeping/p/6632158.html
總結
以上是生活随笔為你收集整理的The 15th UESTC Programming Contest Preliminary C - C0ins cdoj1554的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Linux系统运维之Zookeeper集
- 下一篇: 集合——PHP实现