mirror of
https://github.com/Kiritow/OJ-Problems-Source.git
synced 2024-03-22 13:11:29 +08:00
b39288d6ef
5400-5504(END by now)
22 lines
406 B
C++
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;
|
|
}
|