zoukankan      html  css  js  c++  java
  • hdu 1309 Loansome Car Buyer

    纯粹的阅读理解题…………

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

        int
    n,i,j,t,k,m[101],l;
        double
    cost,sum,car,p[101],s;
        while
    (cin>>t>>cost>>sum>>k)
        {

            if
    (t<0)
                break
    ;
            j=0;
            for
    (i=0;i<k;i++)
            {

                cin>>l>>s;
                if
    (i==0)
                    p[j++]=s;
                else

                {

                    while
    (j<l)
                    {

                        p[j]=p[j-1];
                        j++;
                    }

                    p[j++]=s;
                }
            }

            while
    (j<=t) {
                p[j]=p[j-1];
                j++;
            }

            car=(sum+cost)*(1-p[0]);
            cost=sum/t;
            if
    (car>=sum)
            {

                cout<<"0 months"<<endl;
                continue
    ;
            }

            j=1;
            for
    (i=1;i<=t;i++)
            {

                s=p[i];
                car*=(1-s);
                sum-=cost;
                if
    (car>=sum)
                    break
    ;
            }

            if
    (i==1)
                cout<<"1 month"<<endl;
            else
    cout<<i<<" months"<<endl;
        }

        return
    0;
    }

  • 相关阅读:
    UVa532 Dungeon Master 三维迷宫
    6.4.2 走迷宫
    UVA 439 Knight Moves
    UVa784 Maze Exploration
    UVa657 The die is cast
    UVa572 Oil Deposits DFS求连通块
    UVa10562 Undraw the Trees
    UVa839 Not so Mobile
    327
    UVa699 The Falling Leaves
  • 原文地址:https://www.cnblogs.com/xin-hua/p/3195333.html
Copyright © 2011-2022 走看看