zoukankan      html  css  js  c++  java
  • HDU 3573 Buy Sticks(数学规律)

    Buy Sticks

    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
    Total Submission(s): 652    Accepted Submission(s): 280


    Problem Description
    Imyourgod need 3 kinds of sticks which have different sizes: 20cm, 28cm and 32cm. However the shop only sell 75-centimeter-long sticks. So he have to cut off the long stick. How many sticks he must buy at least.
     
    Input
    The first line of input contains a number t, which means there are t cases of the test data.
    There will be several test cases in the problem, each in one line. Each test cases are described by 3 non-negtive-integers separated by one space representing the number of sticks of 20cm, 28cm and 32cm. All numbers are less than 10^6.
     
    Output
    The output contains one line for each line in the input case. This line contains the minimal number of 75-centimeter-long sticks he must buy. Format are shown as Sample Output.
     
    Sample Input
    2 3 1 1 4 2 2
     
    Sample Output
    Case 1: 2 Case 2: 3
     
    Author
    imyourgod (Special Thanks : crackerwang & Louty)
     
    Source
     
    Recommend
    zhouzeyong
     
     
     
    20+20+28 或者 20 + 20 + 30;
    20+20+20
    28(30)+28(30)
     
    先筹三个的,后两个的
     
    #include<stdio.h>
    #include<iostream>
    using namespace std;
    int main()
    {
     //   freopen("in.txt","r",stdin);
    //    freopen("out.txt","w",stdout);
        int T;
        int a,b,c;
        int iCase=0;
        scanf("%d",&T);
        while(T--)
        {
            iCase++;
            scanf("%d%d%d",&a,&b,&c);
            int res;
            if((b+c)*2>=a) res=a/2+(b+c-a/2+a%2+1)/2;
            else res=(b+c)+(a-(b+c)*2+2)/3;
            printf("Case %d: %d\n",iCase,res);
        }
        return 0;
    }
  • 相关阅读:
    Oracle FGA审计记录的清理步骤
    UVa11488-Hyper Prefix Sets(trie树)
    配置Log4j(非常具体)
    poj1190生日蛋糕
    zju1610Count the Colors
    【例9.3】求最长不下降序列
    P1364 医院设置
    P1629 邮递员送信
    P1476 休息中的小呆
    P1330 封锁阳光大学
  • 原文地址:https://www.cnblogs.com/kuangbin/p/2622296.html
Copyright © 2011-2022 走看看