|
|
back to boardWA on Test 21 - Cn smbdy help me? 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 |
|
|