• hdu 1288 Hat's Tea


    这个要慢慢理解……

    #include<iostream>
    #include<stdio.h>
    #include<algorithm>
    #include<iomanip>
    #include<cmath>
    #include<string>
    using namespace std;
    int
    main()
    {

        int
    n,i,j,k,a1,a5,a10;
        bool
    flag;
        while
    (cin>>n>>a1>>a5>>a10&&(n+a1+a5+a10))
        {

            i=j=k=0;
            if
    (n%5>a1)
            {

                cout<<"Hat cannot buy tea."<<endl;
                continue
    ;
            }

            i=n%5;
            n-=i;
            a1-=i;
            if
    (n<=a1)
            {

                i+=n;
                printf("%d YiJiao, %d WuJiao, and %d ShiJiao ",i,j,k);
                continue
    ;
            }

            a1/=5;
            n-=5*a1;
            i+=5*a1;
            if
    (n<=5*a5)
            {

                j+=n/5;
                printf("%d YiJiao, %d WuJiao, and %d ShiJiao ",i,j,k);
                continue
    ;
            }

            n-=5*a5;
            j=a5;
            if
    (n%10==0)
            {

                if
    (n<=10*a10)
                {

                    k=n/10;
                    printf("%d YiJiao, %d WuJiao, and %d ShiJiao ",i,j,k);
                    continue
    ;
                }

                else

                {

                    cout<<"Hat cannot buy tea."<<endl;
                    continue
    ;
                }
            }

            else

            {

                if
    (j>0)
                    j--;
                else

                {

                    if
    (i>=5)
                        i-=5;
                    else

                    {

                        cout<<"Hat cannot buy tea."<<endl;
                        continue
    ;
                    }
                }

                n+=5;
                if
    (n<=10*a10)
                {

                    k=n/10;
                    printf("%d YiJiao, %d WuJiao, and %d ShiJiao ",i,j,k);
                    continue
    ;
                }

                else

                {

                    cout<<"Hat cannot buy tea."<<endl;
                    continue
    ;
                }
            }
        }

        return
    0;
    }

  • 相关阅读:
    web.xml+spring mvc基本配置
    REST服务安全-双向认证
    thymeleaf 配置
    jenkins
    linux下ssh/scp无密钥登陆方法
    java编译 Error: Could not find or load main class java执行包main方法
    文本按列导入excel
    linux脚本-判断进程是否存在,从而可以做预警处理..
    Linux中顿号
    >/dev/null 2>&1
  • 原文地址:https://www.cnblogs.com/xin-hua/p/3194479.html
Copyright © 2020-2023  润新知