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

    版权声明:本文为博主原创文章,未经博主允许不得转载。http://xiang578.top/

  • 相关阅读:
    第二周作业
    7-2 求最大值及其下标
    第十一周作业
    第九周编程总结
    第八周作业
    第七周作业
    第六周作业
    第五周作业
    第4周作业
    第三周作业
  • 原文地址:https://www.cnblogs.com/xryz/p/4847824.html
Copyright © 2011-2022 走看看