zoukankan      html  css  js  c++  java
  • 构造 BestCoder Round #52 (div.2) 1001 Victor and Machine

    题目传送门

    题意:有中文版

    分析:首先要知道机器关闭后,w是清零的。所以一次(x + y)的循环弹出的小球个数是固定的,为x / w + 1,那么在边界时讨论一下就行了

    收获:这种题目不难,理解清楚题意,yy出可行的解法总能做出来

    代码:

    /************************************************
    * Author        :Running_Time
    * Created Time  :2015-8-22 18:55:05
    * File Name     :A.cpp
     ************************************************/
    
    #include <cstdio>
    #include <algorithm>
    #include <iostream>
    #include <sstream>
    #include <cstring>
    #include <cmath>
    #include <string>
    #include <vector>
    #include <queue>
    #include <deque>
    #include <stack>
    #include <list>
    #include <map>
    #include <set>
    #include <bitset>
    #include <cstdlib>
    #include <ctime>
    using namespace std;
    
    #define lson l, mid, rt << 1
    #define rson mid + 1, r, rt << 1 | 1
    typedef long long ll;
    const int N = 1e5 + 10;
    const int INF = 0x3f3f3f3f;
    const int MOD = 1e9 + 7;
    
    int main(void)    {
        int x, y, w, n;
        while (scanf ("%d%d%d%d", &x, &y, &w, &n) == 4)	{
            int cnt = 0;
            int t = 0;
            int a = x / w + 1;
            while (cnt + a <= n)	{
                cnt += a;
                if (cnt == n)	{
                    t += (a - 1) * w;	break;
                }
                else if (cnt == n - 1)	{
                    t += x + y;	break;
                }
    			else t += (x + y);
            }
            if (cnt == n || cnt == n - 1)	{
                printf ("%d
    ", t);	continue;
            }
            cnt++;		//忘写,WA一次
            while (cnt < n)	{
                t += w;
                cnt++;
            }
            printf ("%d
    ", t);
        }
    
        return 0;
    }
    

      

    编译人生,运行世界!
  • 相关阅读:
    SCAU 9504 面试
    SCAU 9503 懒人选座位
    SCAU 8628 相亲
    SCAU 10691 ACM 光环
    SCAU 8626 原子量计数
    SCAU 10674 等差对
    HDU ACM 1048 The Hardest Problem Ever (水题)
    SCAU 9502 ARDF
    SCAU 10686 DeathGod不知道的事情
    SCAU 8629 热身游戏(高精度)
  • 原文地址:https://www.cnblogs.com/Running-Time/p/4751258.html
Copyright © 2011-2022 走看看