#257
Se dă un număr natural n
. Să se descompună în sumă cu număr minim de termeni ai şirului lui Fibonacci.
Problema | FiboSum | Operații I/O |
![]() |
---|---|---|---|
Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
Id soluție | #58500109 | Utilizator | |
Fișier | fibosum.cpp | Dimensiune | 684 B |
Data încărcării | 11 Iunie 2025, 19:49 | Scor / rezultat | Eroare de compilare |
fibosum.cpp: In function 'int main()': fibosum.cpp:19:19: error: no match for 'operator[]' (operand types are 'std::vector<int>' and 'std::initializer_list<unsigned int>') while(sFib[i] > n){ ^ fibosum.cpp:19:19: note: candidates are: In file included from /usr/include/c++/4.8/vector:64:0, from fibosum.cpp:2: /usr/include/c++/4.8/bits/stl_vector.h:770:7: note: std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::reference = int&; std::vector<_Tp, _Alloc>::size_type = unsigned int] operator[](size_type __n) ^ /usr/include/c++/4.8/bits/stl_vector.h:770:7: note: no known conversion for argument 1 from 'std::initializer_list<unsigned int>' to 'std::vector<int>::size_type {aka unsigned int}' /usr/include/c++/4.8/bits/stl_vector.h:785:7: note: std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) const [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::const_reference = const int&; std::vector<_Tp, _Alloc>::size_type = unsigned int] operator[](size_type __n) const ^ /usr/include/c++/4.8/bits/stl_vector.h:785:7: note: no known conversion for argument 1 from 'std::initializer_list<unsigned int>' to 'std::vector<int>::size_type {aka unsigned int}' fibosum.cpp:20:14: error: no match for 'operator-=' (operand types are 'std::initializer_list<unsigned int>' and 'int') i-=1; ^ fibosum.cpp:22:24: error: no match for 'operator[]' (operand types are 'std::vector<int>' and 'std::initializer_list<unsigned int>') std::cout<<sFib[i]<<' '; ^ fibosum.cpp:22:24: note: candidates are: In file included from /usr/include/c++/4.8/vector:64:0, from fibosum.cpp:2: /usr/include/c++/4.8/bits/stl_vector.h:770:7: note: std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::reference = int&; std::vector<_Tp, _Alloc>::size_type = unsigned int] operator[](size_type __n) ^ /usr/include/c++/4.8/bits/stl_vector.h:770:7: note: no known conversion for argument 1 from 'std::initializer_list<unsigned int>' to 'std::vector<int>::size_type {aka unsigned int}' /usr/include/c++/4.8/bits/stl_vector.h:785:7: note: std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) const [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::const_reference = const int&; std::vector<_Tp, _Alloc>::size_type = unsigned int] operator[](size_type __n) const ^ /usr/include/c++/4.8/bits/stl_vector.h:785:7: note: no known conversion for argument 1 from 'std::initializer_list<unsigned int>' to 'std::vector<int>::size_type {aka unsigned int}' fibosum.cpp:23:17: error: no match for 'operator[]' (operand types are 'std::vector<int>' and 'std::initializer_list<unsigned int>') n-= sFib[i]; ^ fibosum.cpp:23:17: note: candidates are: In file included from /usr/include/c++/4.8/vector:64:0, from fibosum.cpp:2: /usr/include/c++/4.8/bits/stl_vector.h:770:7: note: std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::reference = int&; std::vector<_Tp, _Alloc>::size_type = unsigned int] operator[](size_type __n) ^ /usr/include/c++/4.8/bits/stl_vector.h:770:7: note: no known conversion for argument 1 from 'std::initializer_list<unsigned int>' to 'std::vector<int>::size_type {aka unsigned int}' /usr/include/c++/4.8/bits/stl_vector.h:785:7: note: std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) const [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::const_reference = const int&; std::vector<_Tp, _Alloc>::size_type = unsigned int] operator[](size_type __n) const ^ /usr/include/c++/4.8/bits/stl_vector.h:785:7: note: no known conversion for argument 1 from 'std::initializer_list<unsigned int>' to 'std::vector<int>::size_type {aka unsigned int}'
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema FiboSum face parte din prima categorie. Soluția propusă de tine va fi evaluată astfel:
Suma punctajelor acordate pe testele utilizate pentru verificare este 100. Astfel, soluția ta poate obține cel mult 100 de puncte, caz în care se poate considera corectă.