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

WA on Test 21 - Cn smbdy help me?
Posted by Michael Medvedev 6 Mar 2006 14:26
WA on test 21:

#include <stdio.h>

double p,q,px,qx,temp;
int x;

void main(void)
{
  scanf("%lf %lf",&p,&q);
  x = 1;
  while(1)
  {
    px = p*x; qx = q*x;
    temp = (int)(qx/100)*100;
    if ((temp > px) && (temp < qx)) break;
    x++;
  }
  printf("%d\n",x);
}

Then I tried to introduce EPSILON, but the same WA on 21:

#include <stdio.h>
#define EPS 1e-15

double p,q,px,qx,temp;
int x;

void main(void)
{
  scanf("%lf %lf",&p,&q);
  x = 1;
  while(1)
  {
    px = p*x; qx = q*x;
    temp = (int)(qx/100+EPS)*100;
    if ((temp > px+EPS) && (temp < qx-EPS)) break;
    x++;
  }
  printf("%d\n",x);
}

P.S. Silly mistake - accepted.

Edited by author 06.03.2006 14:28

Edited by author 06.03.2006 14:29