OJ-Problems-Source/HDOJ/5417_autoAC.cpp
KiritoTRw b39288d6ef Powered By HC TECH : AutoACer Engine
5400-5504(END by now)
2016-09-13 04:55:33 +08:00

22 lines
406 B
C++

#include <iostream>
using namespace std;
int main()
{
int x, y, w, n;
while(cin>>x>>y>>w>>n)
{
n -= 1;
int ans, tmp1, tmp2;
if(w > x)
ans = (x+y)*n;
else
{
tmp1 = n % ((int)(x/w)+1);
tmp2 = n / (x/w+1);
ans = tmp2*(x+y)+w*tmp1;
}
cout<<ans<<endl;
}
return 0;
}