Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
While making a vaccine for COVID-19, the scientists generated a new virus by mistake and it is more dangerous than the coronavirus. So they planned to kill the virus in the lab where they generated the virus by mistake to avoid it's spread. The only way to kill the virus is by the electric rod of very high voltage. Since very high voltage is passing through the electric rod, it cuts off some amount of voltage after every
X minutes to avoid any type of accident. So the scientists again maximize the voltage intensity of the electric rod after every Y minute. The electric rod gets very high voltage and low voltage instantly.It is known that to kill the virus, scientists havetogive K minutes of very high voltage or 2∗K
minutes of low voltage. They want to find how much time they have to give the electric shock to kill the virus by assuming that virus is getting the very high voltage and low voltage evenly.
input format
The single line contains three space-separated integers X,Y,K.
Output format
Print a single number, the total time to kill the virus in minutes. Print 8 digits after the decimal.
Constraints
1<=X,Y,K<=10 raised to 10
Input
4 2 7

Output
7.00000000

Sample test case explanation
X=4and Y=2, so in every2 minute scientists check whether the voltage is low or high. If it is low then they maximize the voltage.
So for the first7 minutes voltage is never low and hence the virus will be killed

What I have tried:

<pre lang="c++">

#include <bits/stdc++.h>
#include<iomanip>
using namespace std;

int main()
{
  //write your code here
  long int X,Y,K;
  cin>>X>>Y>>K;
  if(X>Y)
  cout<<setprecision(8)<<K;
  else
  cout<<setprecision(8)<<2*K;
  
  
  return 0;
}
Posted
Updated 23-Aug-20 20:20pm

We are more than willing to help those that are stuck: but that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you. Plus, if we just "hand you the solution" you don't learn anything useful from that, and the next time you have to do a similar task you have to ask again, and again, and again ... people learn by doing, not by looking at results!

So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in!
Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did. If you don't understand the question, talk to you tutor so he can explain it to you.

Just posting your homework with a comment "write your code here" isn't going to get you anywhere.
 
Share this answer
 
in the above question we need to setprecision and for some reason I can't get it.
can someone suggest a way of doing it.
 
Share this answer
 
Comments
Richard MacCutchan 24-Aug-20 3:34am    
Nothing in your question suggests that you should use the setprecision function. What it does ask you to do is to print 8 digits after the decimal point. So you need to write the code to calculate the answer as a real decimal number.
KarstenK 24-Aug-20 4:55am    
you need the precision ONLY for the formatted output. This is normal an aspect of "beautifying" the UI.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900