zoukankan      html  css  js  c++  java
  • hdu 5417 Victor and Machine

    #include <stdio.h>
    #include <string.h>
    #include <iostream>
    #include <algorithm>
    #include <vector>
    #include <queue>
    #include <stack>
    #include <set>
    #include <map>
    #include <string>
    #include <math.h>
    #include <stdlib.h>
    #include <time.h>
    using namespace std;
    
    int main()
    {
        int x,y,w,n,ans,i,tp;
        while(~scanf("%d%d%d%d",&x,&y,&w,&n))
        {
           tp=x/w+1;
           ans=(n-1)/tp*(x+y)+(n-1)%tp*w;
            printf("%d
    ",ans);
        }
        return 0;
    }
    #include <stdio.h>
    #include <string.h>
    #include <iostream>
    #include <algorithm>
    #include <vector>
    #include <queue>
    #include <stack>
    #include <set>
    #include <map>
    #include <string>
    #include <math.h>
    #include <stdlib.h>
    #include <time.h>
    using namespace std;
    
    int main()
    {
        int x,y,w,n,ans,i,tp;
        while(~scanf("%d%d%d%d",&x,&y,&w,&n))
        {
            i=1;
            ans=tp=0;
            while(i<n)
            {
                if(ans+w<tp+x)
                {
                    ans+=w;
                    i++;
                }
                else if(ans+w==tp+x)
                {
                    i++;
                    tp+=x;
                    ans=tp;
                    if(i==n) break;
                    i++;
                    tp+=y;
                    ans=tp;
                }
                else if(ans+w>tp+x)
                {
                    i++;
                    tp=tp+x+y;
                    ans=tp;
                }
            }
            printf("%d
    ",ans);
        }
        return 0;
    }
    
  • 相关阅读:
    链表详解自带代码
    队列
    单词翻转
    表达式求值
    一元多项式
    循环链表
    学生成绩管理系统
    双向循环链表
    双向链表
    静态链表
  • 原文地址:https://www.cnblogs.com/blfbuaa/p/7060283.html
Copyright © 2011-2022 走看看