Show all threads Hide all threads Show all messages Hide all messages |
Why does it return compilation error? I'm using GCC compilator. | satybal | 1001. Reverse Root | 12 Mar 2024 13:34 | 1 |
#include <iostream> #include <vector> #include <cmath> using namespace std; int main() { double number; vector<double> numbers; while (cin >> number) numbers.push_back(number); cout.precision(4); cout.setf(std::ios::fixed); for (auto iter = numbers.rbegin(); iter != numbers.rend(); ++iter) cout << sqrt(*iter) << endl; return 0; } |
problem 1001 c++ | Vasilisa | 1001. Reverse Root | 18 Feb 2024 11:36 | 1 |
//please tell me what's wrong, cause i cant understand... #include <bits/stdc++.h> #include<fstream> #define all(a) (a).begin(), (a).end() #define ll long long #define sz size #define dbl double #define vll vector <ll> #define INF LLONG_MAX #define uniq(x) x.resize(unique(begin(x),end(x))-begin(x)) #define forik(i,m,n) for(ll i=m;i<n;++i) #define re return using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(); vll numbers; ll num; while (cin >> num) { numbers.push_back(num); } for (ll i = numbers.size() - 1; i >= 0; i--) { dbl nek = sqrt(numbers[i]); cout << fixed << setprecision(4) << nek << endl; } re 0; } |
I don't know what is wrong with my code, could I use stack here? | JK Love | 1001. Reverse Root | 16 Feb 2024 11:59 | 2 |
#include <iostream> #include <stack> #include <cmath> using namespace std; int main() { stack<double> root; double input;
while(cin >> input) { root.push(sqrt(input)); }
while(!root.empty()) { cout << root.top() << endl; root.pop(); }
return 0; } Here your first input while is going infinnity. You have to stop it. |
What wrong? (с++) | Plotnik | 1001. Reverse Root | 11 Jan 2024 19:59 | 1 |
#include <iostream> #include <algorithm> #include <iomanip> #include <string> #include <vector> #include <cmath> using namespace std; int main() { double element, a; vector<double> numbers; while (cin >> element) { numbers.push_back(element); } reverse(numbers.begin(), numbers.end()); for (size_t i = 0; i != numbers.size(); i++) { a = sqrt(numbers[i]); cout << setprecision(4) << a << "\n"; } return 0; } Edited by author 11.01.2024 20:23 |
How can the program recognize when there aren´t more inputs (python3)? | HUC_EDDIE | 1001. Reverse Root | 9 Jan 2024 02:50 | 2 |
How can the program recognize when there aren´t more inputs if use python3 ? my program: nums = [int(x) for x in input().split()] nums.reverse() for num in nums: print('{:.4f}'.format(num ** 0.5)) What's wrong? anyone can tell me ,pls Edited by author 29.11.2023 07:42 Edited by author 29.11.2023 07:43 The answer to your question is in the FAQ, page How to write Python solutions. |
What's wrong? | Volodimir | 1001. Reverse Root | 9 Dec 2023 04:33 | 2 |
#include <iostream> using namespace std; int main() { double k; while(cin >> k) { cout << fixed << setprecision(4) << sqrt(k) << endl; } } I think the solution is supposed to start from the last number |
I don't undesrstand where is a mistake. Who can help? | Danis | 1001. Reverse Root | 6 Nov 2023 18:42 | 1 |
lines = [] for line in stdin: for i in range(0, len(line.split())): lines.append(line.split()[i]) lines = [int(i) for i in lines] lines_rev = list(reversed(lines)) numbers = [] for i in range(0, len(lines_rev)): numbers.append(lines_rev[i]**0.5) for i in range(len(numbers)): print(f"{numbers[i]:.4f}") |
wrong answer C++ | Igor | 1001. Reverse Root | 20 Mar 2023 12:40 | 1 |
I want to solve the problem using a dynamic array. But the compiler outputs this: HEAP CORRUPTION DETECTED: after Normal block (#150) at 0x000001EEFBCDB420. CRT detected that the application wronte to memory after end of heap buffer. #include <iostream> #include <cmath> #include <iomanip> using namespace std; void main() { int size = 0, i = 0; int* a = new int[size]; unsigned int x; while (cin >> x) { size += 1; for (; i < size;++i) { a[i] = x;
} }
for (int i = size-1; i >= 0; --i) { cout << fixed << setprecision(4) << sqrt(a[i]) << endl; } delete[] a; Edited by author 20.03.2023 12:40 |
I don't understand this task | Reveek | 1001. Reverse Root | 13 Mar 2023 15:35 | 2 |
When need stop the flow. Help me pls! Try use any symbol, i.e. "\" when need to stop |
Wrong answer UPD: solved | dry9goincer | 1001. Reverse Root | 7 Mar 2023 20:37 | 1 |
using System; public class Reverse { private static void Main() { string[] numbers = Console.ReadLine().Split(new char[] {' ', '\t', '\n', '\r'}, StringSplitOptions.RemoveEmptyEntries);
for(int i = numbers.Length-1; i >= 0; i--) { double result = Math.Sqrt(double.Parse(numbers[i])); Console.WriteLine($"{result:F4}"); } } } Edited by author 07.03.2023 20:45 |
C++ not pass 2 test | andrey | 1001. Reverse Root | 27 Feb 2023 20:43 | 1 |
#include <cstdlib> #include <iomanip> #include <iostream> #include <cstdio> #include <math.h> #include <vector> #include <string.h> #include <algorithm> using namespace std; vector <double> numbers = {}; int main(int argc, const char * argv[]) { double n; while (std::cin >> n) { numbers.push_back(n); if (cin.peek() == '\n' ){ reverse(numbers.begin(),numbers.end()); for(int i = 0;i < numbers.size();++i){ cout<<fixed<<setprecision(4)<<sqrt(numbers[i])<<endl; } break; }; }
return 0; } I have a correct answer with input numbers in sample, and i see message "wrong answer" in 2 test. First test was passed, but i don't see where i lose... |
Why I am getting TLE in c++ ? Please help. | Muhammad Abdullah | 1001. Reverse Root | 31 Dec 2022 00:29 | 6 |
#include <bits/stdc++.h> using namespace std; int main(){ long long n, res; vector <long long> vt; while(cin>>n){ vt.push_back(n); } int len = vt.size();
for(int i = len-1; i >= 0; i--){ double n = sqrt(vt[i]); printf("%0.4lf\n", n); } return 0; } Edited by author 07.09.2019 11:05 Edited by author 07.09.2019 11:11 while(cin>>n) .... Its an infinite loop. My AC solution also used while (cin >> n) double instead of long long while declaring n and vector. |
Why is my code in python language wrong? | Mayari Villalba | 1001. Reverse Root | 27 Dec 2022 14:21 | 2 |
a=[int(i) for i in input().split()] for i in a[::-1]: print(f"{float(i)**0.5:.4f}") because u proggram should take more one string. But i too not lnow how solve this task Edited by author 27.12.2022 14:22 |
(C++) Why runtime error happened? | ThomasLin | 1001. Reverse Root | 6 Oct 2022 14:08 | 1 |
#include <iostream> #include <vector> #include <iomanip> #include <cmath> using namespace std; int main (){ double Input=0 ; double number[] ; int counter=0; while ( cin >> Input && Input != EOF){ number[counter] = Input; cout << number[counter]; counter++ ; } for (int i=counter ; i>0; i--){ cout << setprecision(4) << sqrt (number[counter]) << endl; } } |
Accepted C# | PI−2016-Trykoza | 1001. Reverse Root | 17 Jul 2022 17:38 | 4 |
* deleted * Edited by moderator 23.07.2022 20:33 We need a ranking for the least amount of code. I think It doesn't matter. Algorithm is important! Thanx a lot! I didn't know how to read all lines from console! Edited by author 17.07.2022 17:39 |
What's wrong out there ? Problem 1001 | Iftekhar | 1001. Reverse Root | 23 Jun 2022 10:04 | 1 |
#include<stdio.h> #include<math.h> int main(){ unsigned long long int a,b,c,d; double Sqrt,Sqrt1,Sqrt2,Sqrt3; scanf("%llu %llu %llu %llu",&a,&b,&c,&d); Sqrt=sqrt(a); Sqrt1=sqrt(b); Sqrt2=sqrt(c); Sqrt3=sqrt(d); printf(" %0.4lf %0.4lf %0.4lf %0.4lf",Sqrt,Sqrt1,Sqrt2,Sqrt3); } Edited by author 23.06.2022 13:46 Edited by author 23.06.2022 13:46 |
Python Wrong answer test#1 | Evgen1yK | 1001. Reverse Root | 17 Jun 2022 14:38 | 2 |
I'm just learning python. Can you please tell me where could be the error? import math data = input() length = len(data) list = [] i = 0 while i < length: if data[i] != " " and data[i] != "\n": end_index = i for j in range(i + 1, length): if data[j] == " " or data[i] == "\n": break end_index += 1 list.insert(0, int(data[i:end_index + 1])) i = end_index + 1 else: i += 1 for e in list: value = round(math.sqrt(e), 4) print(f'{value:.4f}') You only need to write about 3 lines of python code to solve this. try: help(str.split) help(reversed) help(str.join) |
GOLANG - WRONG ANSWER | 13kander | 1001. Reverse Root | 14 Apr 2022 14:47 | 1 |
package main import( "fmt" "strings" "bufio" "os" "strconv" "math" ) func main(){ scanner := bufio.NewScanner(os.Stdin) scanner.Scan() line := scanner.Text() s := strings.Fields(line)
for ix := len(s) - 1; ix >= 0; ix--{ i, _ := strconv.Atoi(s[ix]) x := fmt.Sprintf("%.4f", math.Sqrt(float64(i))) fmt.Println(x) } } |
How can the program recognize when there aren´t more inputs ? | Albert | 1001. Reverse Root | 26 Feb 2022 22:10 | 3 |
I investigated on internet, but most of the answers were putting a type of character that breaks the cycle, but in the input example there´s no character and it´s not enough with a "while(cin >> n)" pls help if copypast test text, it read a blank string as EOF by some reason Edited by author 26.02.2022 22:11 |
C++ What's wrong? | Ilia | 1001. Reverse Root | 20 Feb 2022 01:03 | 3 |
#include <iostream> #include <vector> #include <cmath> using namespace std; int main() { double val = 0; vector<double> v; char ch = 0; while (cin >> val) { v.push_back(val); } for (int i = 0; i < v.size(); i++) { cout << sqrt(v[i]) << endl; } } OK. Read this carefully: "For each number Ai from the LAST one till the FIRST one..." Second for loop cout from last element of the vector to first |