|
|
вернуться в форумWrong answer (C) The tests from example and few other are ok, but it gets wrong answer in test1. #include <math.h> #include <stdio.h> #define SIZE (256 * 1024) / sizeof(long long) long long int n[SIZE + 1]; int main(void) { int s = 0, l; do{ l = scanf("%lld", &(n[s])); s++; } while(l != EOF); s -= 2; for(;s >= 0; s--) printf("%.4Lf\n", sqrtl(n[s])); return 0; } Re: Wrong answer (C) The problem here is that system accepts printf("%.4f\n", sqrt(n[s])); but does not accept printf("%.4Lf\n", sqrtl(n[s])); It is a bit strange because the second version is more precise. It would be great if some one showed a false test for the second variant. Re: Wrong answer (C) Maybe you were printing something like 1.23456e-789? To admins Re: Wrong answer (C) No, L is a modifier for extended data type. To be sure I tried the following variant: printf("%.4Lf\n", sqrt((double)n[s])); and it passed. So the only problem is difference between sqrt and sqrtl. To admins: I think that at least one of the tests gives different values when using sqrt and sqrtl. And more precise variant fails. Please check my guess, I think that using of both functions should be valid. |
|
|