Problem : 5417 ( Victor and Machine ) Judge Status : Accepted
RunId : 14606690 Language : G++ Author : Stool_Monster
RunId : 14606690 Language : G++ Author : Stool_Monster
Code Render Status : Rendered By HDOJ G++ Code Render Version 0.01 Beta
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#define LL long long
#define del(a,b) memset(a,b,sizeof(a))
const int INF=99999999;
using namespace std;
int x,y,w,n;
int tmp,mul,ans;
int main(){
while(scanf("%d%d%d%d",&x,&y,&w,&n)!=EOF){
tmp=x/w+1;
//cout<<tmp<<" ";
mul=(n-1)/tmp;
//cout<<mul<<" ";
ans=(x+y)*mul;
//cout<<ans<<" ";
n-=mul*tmp;
//cout<<n<<endl;
n--;
while(n--){
ans+=w;
}
printf("%d\n",ans);
}
}