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;
    }
    

      

    编译人生,运行世界!
  • 相关阅读:
    Hard Rock
    Codeforces Round #416 (Div. 2) B. Vladik and Complicated Book
    codeforces 793B. Igor and his way to work
    codeforces 1B Spreadsheets
    HDU 1069 Monkey and Banana
    codeforces 2B The least round way
    【机器学习】 通俗说拟合
    python-八皇后问题
    python-核心知识思维导图
    python-@property 属性
  • 原文地址:https://www.cnblogs.com/Running-Time/p/4751258.html
Copyright © 2011-2022 走看看