This is Solution To Problem Hangover on POJ and i think the Logic is Correct but My Solution is not Working on POJ Compiler but it's Working Correct on My g++ Compiler.What's Wrong with My Solution. Here is the Problem Link. http://poj.org/problem?id=1003
I Tried To think what is Wrong and i think there is something Wrong how poj take input output and how i am providing.
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
float desired=1.00;
while(1)
{
cin>>desired;
if(desired!=0 and desired<=5.20 and desired>=0.01)
{
float sum=0;
int denominator=2;
float num=1;
int total=0;
while(sum<=desired)
{
num=1.00/denominator;
sum+=num;
total+=1;
++denominator;
}
cout<<total<<"\n";
}
else
exit(0);
}
return 0;
}
I expect my Solution is True but i can't think where i am wrong.
Aucun commentaire:
Enregistrer un commentaire