HDU 5417-Victor and Machine(水题)

来源:互联网 发布:蒙泰设置打印端口 编辑:程序博客网 时间:2024/05/22 15:47

题目地址:HDU 5417
题意:Victor有一个机器,这个机器每次开启的瞬间会弹出一个小球,之后每隔ww秒会弹出一个小球。因为机器不是很完善,该机器每开启xx秒就得关闭yy秒进行调整,在机器关闭的瞬间可能会有小球弹出,关闭之后一直到下一次开启之前都不会有小球弹出。00时刻,机器第一次开启,Victor想要知道第nn个小球弹出的时刻,你能够告诉他吗?

#include <stdio.h>#include <math.h>#include <string.h>#include <stdlib.h>#include <iostream>#include <sstream>#include <algorithm>#include <set>#include <queue>#include <stack>#include <map>#include <bitset>//#pragma comment(linker, "/STACK:102400000,102400000")using namespace std;typedef long long  LL;const int inf=0x3f3f3f3f;const double pi= acos(-1.0);const double esp=1e-7;int main(){    int x,y,w,n;    while(~scanf("%d %d %d %d",&x,&y,&w,&n)){        if(n==1) printf("0\n");        else{            int cnt=1;            int t1=0,t2=0;            int time=0;            int s=0;            while(cnt<n){                    s+=w;                    if(s<=x){                    time+=w;                    }                    else{                    time=(t1+1)*x+(t2+1)*y;                    t1++;                    t2++;                    s=0;                }                cnt++;            }            printf("%d\n",time);        }    }    return 0;}
1 0
原创粉丝点击