您的位置:首页 > 其它

hdu 5417 Victor and Machine(模拟)

2015-08-23 09:56 246 查看

题意:

Victor有一个机器,这个机器每次开启的瞬间会弹出一个小球,之后每隔www秒会弹出一个小球。因为机器不是很完善,该机器每开启xxx秒就得关闭yyy秒进行调整,在机器关闭的瞬间可能会有小球弹出,关闭之后一直到下一次开启之前都不会有小球弹出。


0时刻,机器第一次开启,Victor想要知道第nnn个小球弹出的时刻,你能够告诉他吗?

解析:

直接模拟就好了。

mymy codecode

[code]#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int x, y, w, n; 

int cal() {
    int cnt = 0, time = 0, ans = 0;
    while(true) {
        for(int i = 0; i <= x; i += w) {
            cnt++;
            if(cnt >= n) return ans;
            ans += w;
        }
        ans = (x + y) * (++time);
    }
    return ans;
}

int main() {
    while(scanf("%d%d%d%d", &x, &y, &w, &n) != EOF) {
        printf("%d\n", cal());
    }
    return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: