|
|
back to board1001 Why wrong answer? #include <stdio.h> #include <math.h> int c; float string[1024]; int i=0,b=0; void main(){ while((scanf("%d",&c)) != EOF){ string[b]=c; b++; } for (i=b-1;i>-1;i--)printf("%f \n",sqrt(string[i])); } Re: 1001 Why wrong answer? Try double instead of float because the numbers can be as large as 10^18. Also the 1024 limit of the array is small, try 1000000. Re: 1001 Why wrong answer? I try, but I have got the same result Re: 1001 Why wrong answer? 1) Sure float is not enough, use double. 2) Also the numbers in input can be about 10^18, and int is also not enough! Use long long. 3) Also there is about 256*1024 = 262 144 bytes in input, so there could be about 131 072 numbers! I edited your code a little and got AC. Re: 1001 Why wrong answer? #include <stdio.h> #include <math.h> long long c; double string[1000000]; long i=0, b=0; void main(){ while((scanf("%d",&c)) != EOF){ string[b]=c; b++; } for (i=b-1;i>-1;i--)printf("%f \n",sqrt(string[i])); } ? Re: 1001 Why wrong answer? Now problem with scanf/printf parameters - for long long "lld" or "I64d"; - for double "lf" So correct to scanf("%lld"... and printf("%lf... and get AC =) Re: 1001 Why wrong answer? Thank you :) |
|
|