#4651
Fie x[1], x[2], ..., x[N] un șir de N numere naturale. Două poziții i și j, cu 1 ≤ i ≤ j ≤ N, definesc secvența [i, j] care va conține numerele x[i], x[i + 1], ..., x[j]. O secvență [i, j] cu proprietatea că suma tuturor elementelor din secvență are cifra de control egală cu 9 o vom denumi secv9. Scrieţi un program care, cunoscând N, numărul de elemente din șir, respectiv x[1], x[2], ..., x[N], elementele din șir, rezolvă următoarele două cerințe:
ONI 2024, clasa a 7-a
| Problema | secv9 | Operații I/O |
secv9.in/secv9.out
|
|---|---|---|---|
| Limita timp | 0.3 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
| Id soluție | #63583762 | Utilizator | |
| Fișier | secv9.cpp | Dimensiune | 1.11 KB |
| Data încărcării | 10 Martie 2026, 12:55 | Scor/rezultat | Eroare de compilare |
secv9.cpp: In function 'int main()': secv9.cpp:47:17: error: no match for 'operator+=' (operand types are 'std::vector<long long int>' and 'long long int') sum += x; ^ secv9.cpp:48:24: error: no match for 'operator%' (operand types are 'std::vector<long long int>' and 'int') pref = sum % 9; ^ secv9.cpp:50:21: error: no match for 'operator>' (operand types are 'std::vector<long long int>' and 'int') if (sum > 0) ^ secv9.cpp:50:21: note: candidates are: In file included from /usr/include/c++/4.8/bits/stl_algobase.h:64:0, from /usr/include/c++/4.8/bits/char_traits.h:39, from /usr/include/c++/4.8/ios:40, from /usr/include/c++/4.8/istream:38, from /usr/include/c++/4.8/fstream:38, from secv9.cpp:1: /usr/include/c++/4.8/bits/stl_pair.h:233:5: note: template<class _T1, class _T2> constexpr bool std::operator>(const std::pair<_T1, _T2>&, const std::pair<_T1, _T2>&) operator>(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) ^ /usr/include/c++/4.8/bits/stl_pair.h:233:5: note: template argument deduction/substitution failed: secv9.cpp:50:23: note: 'std::vector<long long int>' is not derived from 'const std::pair<_T1, _T2>' if (sum > 0) ^ In file included from /usr/include/c++/4.8/bits/stl_algobase.h:67:0, from /usr/include/c++/4.8/bits/char_traits.h:39, from /usr/include/c++/4.8/ios:40, from /usr/include/c++/4.8/istream:38, from /usr/include/c++/4.8/fstream:38, from secv9.cpp:1: /usr/include/c++/4.8/bits/stl_iterator.h:309:5: note: template<class _Iterator> bool std::operator>(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_Iterator>&) operator>(const reverse_iterator<_Iterator>& __x, ^ /usr/include/c++/4.8/bits/stl_iterator.h:309:5: note: template argument deduction/substitution failed: secv9.cpp:50:23: note: 'std::vector<long long int>' is not derived from 'const std::reverse_iterator<_Iterator>' if (sum > 0) ^ In file included from /usr/include/c++/4.8/bits/stl_algobase.h:67:0, from /usr/include/c++/4.8/bits/char_traits.h:39, from /usr/include/c++/4.8/ios:40, from /usr/include/c++/4.8/istream:38, from /usr/include/c++/4.8/fstream:38, from secv9.cpp:1: /usr/include/c++/4.8/bits/stl_iterator.h:359:5: note: template<class _IteratorL, class _IteratorR> bool std::operator>(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_IteratorR>&) operator>(const reverse_iterator<_IteratorL>& __x, ^ /usr/include/c++/4.8/bits/stl_iterator.h:359:5: note: template argument deduction/substitution failed: secv9.cpp:50:23: note: 'std::vector<long long int>' is not derived from 'const std::reverse_iterator<_Iterator>' if (sum > 0) ^ In file included from /usr/include/c++/4.8/bits/stl_algobase.h:67:0, from /usr/include/c++/4.8/bits/char_traits.h:39, from /usr/include/c++/4.8/ios:40, from /usr/include/c++/4.8/istream:38, from /usr/include/c++/4.8/fstream:38, from secv9.cpp:1: /usr/include/c++/4.8/bits/stl_iterator.h:1079:5: note: template<class _IteratorL, class _IteratorR> bool std::operator>(const std::move_iterator<_Iterator>&, const std::move_iterator<_IteratorR>&) operator>(const move_iterator<_IteratorL>& __x, ^ /usr/include/c++/4.8/bits/stl_iterator.h:1079:5: note: template argument deduction/substitution failed: secv9.cpp:50:23: note: 'std::vector<long long int>' is not derived from 'const std::move_iterator<_Iterator>' if (sum > 0) ^ In file included from /usr/include/c++/4.8/bits/stl_algobase.h:67:0, from /usr/include/c++/4.8/bits/char_traits.h:39, from /usr/include/c++/4.8/ios:40, from /usr/include/c++/4.8/istream:38, from /usr/include/c++/4.8/fstream:38, from secv9.cpp:1: /usr/include/c++/4.8/bits/stl_iterator.h:1085:5: note: template<class _Iterator> bool std::operator>(const std::move_iterator<_Iterator>&, const std::move_iterator<_Iterator>&) operator>(const move_iterator<_Iterator>& __x, ^ /usr/include/c++/4.8/bits/stl_iterator.h:1085:5: note: template argument deduction/substitution failed: secv9.cpp:50:23: note: 'std::vector<long long int>' is not derived from 'const std::move_iterator<_Iterator>' if (sum > 0) ^ In file included from /usr/include/c++/4.8/string:52:0, from /usr/include/c++/4.8/bits/locale_classes.h:40, from /usr/include/c++/4.8/bits/ios_base.h:41, from /usr/include/c++/4.8/ios:42, from /usr/include/c++/4.8/istream:38, from /usr/include/c++/4.8/fstream:38, from secv9.cpp:1: /usr/include/c++/4.8/bits/basic_string.h:2606:5: note: template<class _CharT, class _Traits, class _Alloc> bool std::operator>(const std::basic_string<_CharT, _Traits, _Alloc>&, const std::basic_string<_CharT, _Traits, _Alloc>&) operator>(const basic_string<_CharT, _Traits, _Alloc>& __lhs, ^ /usr/include/c++/4.8/bits/basic_string.h:2606:5: note: template argument deduction/substitution failed: secv9.cpp:50:23: note: 'std::vector<long long int>' is not derived from 'const std::basic_string<_CharT, _Traits, _Alloc>' if (sum > 0) ^ In file included from /usr/include/c++/4.8/string:52:0, from /usr/include/c++/4.8/bits/locale_classes.h:40, from /usr/include/c++/4.8/bits/ios_base.h:41, from /usr/include/c++/4.8/ios:42, from /usr/include/c++/4.8/istream:38, from /usr/include/c++/4.8/fstream:38, from secv9.cpp:1: /usr/include/c++/4.8/bits/basic_string.h:2618:5: note: template<class _CharT, class _Traits, class _Alloc> bool std::operator>(const std::basic_string<_CharT, _Traits, _Alloc>&, const _CharT*) operator>(const basic_string<_CharT, _Traits, _Alloc>& __lhs, ^ /usr/include/c++/4.8/bits/basic_string.h:2618:5: note: template argument deduction/substitution failed: secv9.cpp:50:23: note: 'std::vector<long long int>' is not derived from 'const std::basic_string<_CharT, _Traits, _Alloc>' if (sum > 0) ^ In file included from /usr/include/c++/4.8/string:52:0, from /usr/include/c++/4.8/bits/locale_classes.h:40, from /usr/include/c++/4.8/bits/ios_base.h:41, from /usr/include/c++/4.8/ios:42, from /usr/include/c++/4.8/istream:38, from /usr/include/c++/4.8/fstream:38, from secv9.cpp:1: /usr/include/c++/4.8/bits/basic_string.h:2630:5: note: template<class _CharT, class _Traits, class _Alloc> bool std::operator>(const _CharT*, const std::basic_string<_CharT, _Traits, _Alloc>&) operator>(const _CharT* __lhs, ^ /usr/include/c++/4.8/bits/basic_string.h:2630:5: note: template argument deduction/substitution failed: secv9.cpp:50:23: note: mismatched types 'const _CharT*' and 'std::vector<long long int>' if (sum > 0) ^ In file included from /usr/include/c++/4.8/vector:64:0, from secv9.cpp:2: /usr/include/c++/4.8/bits/stl_vector.h:1434:5: note: template<class _Tp, class _Alloc> bool std::operator>(const std::vector<_Tp, _Alloc>&, const std::vector<_Tp, _Alloc>&) operator>(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y) ^ /usr/include/c++/4.8/bits/stl_vector.h:1434:5: note: template argument deduction/substitution failed: secv9.cpp:50:23: note: mismatched types 'const std::vector<_Tp, _Alloc>' and 'int' if (sum > 0) ^ In file included from /usr/include/c++/4.8/bits/stl_algobase.h:67:0, from /usr/include/c++/4.8/bits/char_traits.h:39, from /usr/include/c++/4.8/ios:40, from /usr/include/c++/4.8/istream:38, from /usr/include/c++/4.8/fstream:38, from secv9.cpp:1: /usr/include/c++/4.8/bits/stl_iterator.h:848:5: note: template<class _Iterator, class _Container> bool __gnu_cxx::operator>(const __gnu_cxx::__normal_iterator<_Iterator, _Container>&, const __gnu_cxx::__normal_iterator<_Iterator, _Container>&) operator>(const __normal_iterator<_Iterator, _Container>& __lhs, ^ /usr/include/c++/4.8/bits/stl_iterator.h:848:5: note: template argument deduction/substitution failed: secv9.cpp:50:23: note: 'std::vector<long long int>' is not derived from 'const __gnu_cxx::__normal_iterator<_Iterator, _Container>' if (sum > 0) ^ In file included from /usr/include/c++/4.8/bits/stl_algobase.h:67:0, from /usr/include/c++/4.8/bits/char_traits.h:39, from /usr/include/c++/4.8/ios:40, from /usr/include/c++/4.8/istream:38, from /usr/include/c++/4.8/fstream:38, from secv9.cpp:1: /usr/include/c++/4.8/bits/stl_iterator.h:842:5: note: template<class _IteratorL, class _IteratorR, class _Container> bool __gnu_cxx::operator>(const __gnu_cxx::__normal_iterator<_IteratorL, _Container>&, const __gnu_cxx::__normal_iterator<_IteratorR, _Container>&) operator>(const __normal_iterator<_IteratorL, _Container>& __lhs, ^ /usr/include/c++/4.8/bits/stl_iterator.h:842:5: note: template argument deduction/substitution failed: secv9.cpp:50:23: note: 'std::vector<long long int>' is not derived from 'const __gnu_cxx::__normal_iterator<_IteratorL, _Container>' if (sum > 0) ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema secv9 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ă.