ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1011. Conductors

!!!!USE ROUNDING!!!
Posted by XSpider 5 Nov 2008 20:28
without round function i got WA #14. When i used it i got AC!
#include <iostream>
#include <cmath>
using namespace std;
double round(double d);
int main()
{double P, Q;
#ifndef ONLINE_JUDGE
 freopen("input.txt", "r", stdin);
 freopen("output.txt", "w", stdout);
#endif
 cin>>P>>Q;
 P/=100;
 Q/=100;
 int i=2;
 while(true)
    {double min=round(i*P);
     double max=round(i*Q);
     int C=int(max);
     if(C>min && C<max && C>=1) break;
     i++;
    }
 cout<<i;
    return 0;
}
//---------------------------------------------------------------------------
double round(double d)
{return floor(d*10000+0.5)/10000;
}
Re: !!!!USE ROUNDING!!!
Posted by Snayde 21 Apr 2013 18:04
thanks