hdu 5417 Victor and Machine

来源:互联网 发布:勇士vs马刺数据统计 编辑:程序博客网 时间:2024/06/05 10:04

题目:点击打开链接


题解:

判断特殊情况

#include <iostream>#include <cstdio>#include <cmath>#include <cstring>using namespace std;int main(){    int x,y,w,n,t,m;    while(scanf("%d%d%d%d",&x,&y,&w,&n)!=EOF)    {        if(n==1)        {            printf("0\n");            continue;//只有一个的话在一开机瞬间就出来了        }        else if(x<w) t=(n-1)*(x+y);//如果x<w,说明只能在每次开机时掉一个,但是最后一个不需要计时,所以(n-1)*(x+y)        else        {            int a=x/w+1;//每个x区间可以出多少个球            if(n%a==0)                t=(n/a)*(x+y)-y-x%w;//减去不出球的区间y和x%w            else                t=(n/a)*(x+y)+(n%a-1)*w;//还差几个就把差的时间加上        }        printf("%d\n",t);    }    return 0;}



害羞

0 0
原创粉丝点击