zoukankan      html  css  js  c++  java
  • HDU 2633 Getting Driving License(模拟)

    Getting Driving License

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


    Problem Description
    Have you got a driving license? Acquiring a driving license brings you a lot of benefits. You will regret for not passing the driving test or getting a driving license in your campus life. Why?College life is filled with much spare time,which you can use to improve yourself in many fields such as driving.
    During the time of taking driving lessons,Samuel met a lot of classmates whose time are occupied by their own work. The fact that they have little time to practice makes getting driving license increasingly difficult. Passing the driving test as soon as possible is suggested by these mates to the our college students who cannot drive.
    Know something about the driving test you can read the information in the background section,however,it is not related with this problem firmly. Surely,you can go to the problem section directly.
    Here is the background information on owning driving licenses in China mainland:
    To get a driving license successfully,you need to take about 4 tests at least.
    The first part is the theory exam which helps you know clearly about the transportation law in China mainland and other driving theory.
    The second is to test you whether you can drive a car forward out and backward in the garage at a very low speed(like aunts moving),move the car from one garage to another and drive out.
    The third section you need to pass is a little difficult than the second test. In this section,you should be able to drive to avoid the obstacles on the road,manage your car pass S formed way(your car's wheels can not be moved onto one of the tracks which leads your way out),after that you may have to make your car pass the 90 degree angle track,then pass the course equipped with very low bridge using one side of your car's wheel and so on.
    The forth part which is test the same day with the third test is called road driving test(but in the problem I designed the time between Part 3 and Part 4 is 1 month,just want to make the problem much easier).As you can refer from the word,it tests the ability of driving on the road,it is more practical and of more importance.
    If you seems not very lucky,you will have fifth section(The problem does not include the 5th part,you can ignore it in solving the problem).In this part you are required to driving at night which involves changing lights in addition . Teachers never taught how to drive at night unless your group is asked to take part in this test. But on the contrary,taught how to driving at night,of course,is necessary. Samuel had an experience of taking the fifth test to get the driving license in the summer of 2008. Tell you a secret,next time you meet a car comes from an opposite direction and the driver of that car does not change his front lights ,it probably means he/she needs special training on how to drive at night.
    To get a driving license,you should pass the 4 parts one by one. For example,if you failed in the section 2,you have to retry for a second time,third time...before you pass. After that you have the opportunity to enter Part 3.
    Here is the problem section you need read patiently:
    Some details you need to know:
    1.The time between the two tests is generally about 1 month(If you fail in the test on your first attempt,you can try it a second time. Fail again the second time he have to go home and retry after 1 month).
    2.And the time from you take the first test to your owning a license is within 2 years.
    3.What's more,the passing score in Part 1 test is 90(that is to say if you get 89 or even lower at your first attempt,a second attempt is needed. You will pass until you get 90 or higher at the second time)and each of the rest parts the passing score is 80 at least.
     
    Input
    The input consists 2 major sections as usual,
    the test cases t,each of the test case involves an integer n and n scores one gets in the test and with n scores he passed the test or he failed to pass in the 2 years(of course here n>=4). All the number here are integers.
     
    Output
    Output is simple. Just output the time one needs to get a driving license (if time is within 2 years)using the format “It takes about m months to get a driving license.”If time is beyond 2 years please output the sentence “He failed to get a driving license within 2 years! ”
     
    Sample Input
    3
    5
    89 90 95 84 80
    7
    80 90 70 80 75 85 80
    7
    80 90 70 70 80 85 85
     
    Sample Output
    It takes about 3 months to get a driving license.
    It takes about 3 months to get a driving license.
    It takes about 4 months to get a driving license.
    Hint: In the first case:first attempt on trying theory test was totally a failure,so he tried a second time the same day and he succeeded. The second test was taken 1 month later,so it cost 1 month so far. Fortunately, he passed. After 1 month he took part 3 and he passed,he waited for another 1 month to attend the part 4 test and succeed. So the total time he needs is 3 months. In the second case:80 90(part 1,passed)70 80(1 months later passed)75 85 (another 1 month he succeed)80(1 month later he passed and he get the license finally).It took 3 months. In the 3rd case the second part he took for three times ,so you need to add another 1 month to the result of the second case. Hope I have made myself understood.
    模拟,第三部分和第四部分有点特殊,前两个部分每月只有两次机会,用完月份加一,考试通过月份加一,注意两年未通过输出时最后没有空格。
    #include <iostream> 
    #include <algorithm> 
    #include <cstring> 
    #include <cstdio>
    #include <vector> 
    #include <queue> 
    #include <cstdlib> 
    #include <iomanip>
    #include <cmath>
    #include <cassert>
    #include <ctime> 
    #include <map> 
    #include <set> 
    using namespace std; 
    #define lowbit(x) (x&(-x)) 
    #define max(x,y) (x>y?x:y) 
    #define min(x,y) (x<y?x:y) 
    #define MAX 100000000000000000 
    #define MOD 1000000007
    #define pi acos(-1.0) 
    #define ei exp(1) 
    #define PI 3.141592653589793238462
    #define ios() ios::sync_with_stdio(false)
    #define INF 1044266558
    #define mem(a) (memset(a,0,sizeof(a)))
    typedef long long ll;
    int n,x,t;
    int main()
    {
        scanf("%d",&t);
        while(t--)
        {
            int pos=1,ok=0,flag=0,k=0;
            scanf("%d",&n);
            for(int i=0;i<n;i++)
            {
                scanf("%d",&x);
                //printf("%d %d
    ",x,pos);
                if(flag==0)
                {
                    if(x<90) ok++;
                    else if(x>=90) {ok=0;pos++,flag=1;continue;}
                    if(ok==2) pos+=1,ok=0;
                }
                else if(flag==1)
                {
                    if(x<80) ok++;
                    else if(x>=80) {ok=0;pos++,flag=2;continue;}
                    if(ok==2) pos+=1,ok=0;
                }
                else if(flag==2)
                {
                    if(k==0)
                    {
                        if(x<80) ok++;
                        else if(x>=80) {ok=0;k=1;continue;}
                        if(ok==2) pos+=1;
                    }
                    else if(k==1)
                    {
                        if(x<80) ok++;
                        else if(x>=80) {ok=0;continue;}
                        if(ok==2) pos+=1;
                    }
                }
            }
            if(pos<=24) printf("It takes about %d months to get a driving license.
    ",pos);
            else printf("He failed to get a driving license within 2 years!
    ");
        }
        return 0;
    }
    /*
    4
    17
    70 70 70 70 95 70 70 70 95 70 70 70 95 70 70 70 95
    5
    89 90 95 84 80
    7
    80 90 70 80 75 85 80
    7
    80 90 70 70 80 85 85
    */
  • 相关阅读:
    bzoj 1051: [HAOI2006]受欢迎的牛
    bzoj 1192: [HNOI2006]鬼谷子的钱袋
    一些动规水题
    USACO 2014 Open Silver Fairphoto
    USACO 2013 Nov Silver Pogo-Cow
    09day1
    09day2
    08day2
    08day1
    07day2
  • 原文地址:https://www.cnblogs.com/shinianhuanniyijuhaojiubujian/p/7344823.html
Copyright © 2011-2022 走看看