-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathbyecakes.cpp
More file actions
46 lines (39 loc) · 708 Bytes
/
byecakes.cpp
File metadata and controls
46 lines (39 loc) · 708 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <bits/stdc++.h>
using namespace std;
int main() {
// your code goes here
int a[8],ans,amt,cake;
float temp;
while(1)
{
ans=cake=amt=INT_MIN;
for(int i=0;i<8;++i)
{
cin>>a[i];
}
if(a[0]==-1 && a[1]==-1 && a[2]==-1 && a[3]==-1 && a[4]==-1 && a[5]==-1 && a[6]==-1 && a[7]==-1)
{
return 0;
}
for(int i=0;i<4;++i)
{
temp=a[i]; //to convert expression into float
temp=ceil(temp/(float)a[i+4]);
//cout<<temp<<";";
cake= ceil(temp); //ceil value
//cout<<cake<<" ";
if(amt< cake)
{
amt= cake;
}
}
//cout<<amt<<endl;
for(int i=0;i<4;++i)
{
ans= (amt*a[i+4])-a[i];
cout<<ans<<" ";
}
cout<<endl;
}
return 0;
}