GeeksforGeeks Solution For School Domain .Below You Can Find The Solution Of Basic ,Easy ,Medium ,Hard .You Can Also Direct Submit Your Solution to Geeksforgeeks Same Problem .You Need to login then you can submit you answers
Problem :- There are n bikes and each can cover 100 km when fully fueled. What is the maximum amount of distance you can go using n bikes? You may assume that all bikes are similar and a bike takes 1 litre to cover 1 km.
The output may contain decimal value but print the integer value of the float value obtained.
Submit Your Solution :- Click Here
Solution :-
#include <iostream>
using namespace std;
int main()
{
int t=0,n,sum;
float i;
float dis;
cin>>t;
while(t--)
{
cin>>n;
dis=0.0;
for(i=1.0f;i<=n;i++)
dis=dis+(100/i);
sum=dis;
cout<<sum<<endl;
}
return 0;
}
Output:-
0 Comments: