#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\n",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\n",ans);
    }
    return 0;
}

相关文章:

  • 2022-12-23
  • 2021-07-01
  • 2022-12-23
  • 2021-10-02
  • 2021-06-02
  • 2022-12-23
  • 2021-08-08
  • 2021-08-15
猜你喜欢
  • 2022-02-25
  • 2021-12-17
  • 2021-11-13
  • 2022-01-20
  • 2022-02-23
  • 2022-12-23
  • 2022-02-28
相关资源
相似解决方案