|  | 
|  | 
| вернуться в форум | Why wrong answer ? HiI am new to forum. I just tried Reverse Root problem and had judgement result as "wrong answer". Below is my code .. just wondering what is wrong with it. Because I ran it on Visual Studio and it seems to give right numbers.
 
 Many Thanks
 -----------------------------------------
 
 
 #include <iostream>
 #include <iomanip>
 #include <cmath>
 int main(){
 double arr[65536];
 int i = 0;
 int value = 0;
 while(std::cin >> value){
 arr[i++] = sqrt(static_cast<double> (value));
 }
 std::cout<<std::setprecision(4)<<std::fixed;
 while(i--)
 std::cout << arr[i] << std::endl;
 }
Re: Why wrong answer ? Послано alex  4 ноя 2012 15:45for example,
 std::cout << std::setprecision(4) << sqrt(641234.123) << std::endl
 
 gives result 800.8.
 
 Presicion isn't in it's natural state.
Re: Why wrong answer ? Послано Song  12 ноя 2012 20:37std::cout << std::setiosflags(ios::fixed) << std::setprecision(4) << your_number << std::endl
 It is important to set ios::fixed flag.
 
 And 2^32 -1 is smaller than 10^18, so an int cannot hold a larger number from input.
 
 Edited by author 12.11.2012 20:39
 | 
 | 
|