zoukankan      html  css  js  c++  java
  • The 15th UESTC Programming Contest Preliminary C

    地址: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. (1X,Y1091≤X,Y≤109)

    Output

    The minimum numbers of coins should be picked.

    Sample input and output

    Sample InputSample 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;
    }

     

  • 相关阅读:
    对《应试教育》有感
    月总结
    有趣的生活,有趣的比赛
    H5之js拼接select级联优化
    H5之js拼接select与input的级联
    OA-分页查询(抽象最终版)二
    OA-分页查询(抽象最终版)一
    今目标反思
    电子商务运作的随想
    旅游票务网站
  • 原文地址:https://www.cnblogs.com/weeping/p/6632158.html
Copyright © 2011-2022 走看看