#4699
moderat
C++
Subprogramul moderat
are un singur parametru, n
, prin care primește un număr natural (n ∈ [1, 1.000.000.000]
). Subprogramul returnează valoarea 1
dacă n
este un număr moderat, sau valoarea 0
în caz contrar. Scrieți definiția completă a subprogramului.
Bac 2024, sesiunea august
Problema | moderat | Operații I/O |
moderat.in /moderat.out
|
---|---|---|---|
Limita timp | 0.1 secunde | Limita memorie |
Total: 2 MB
/
Stivă 1 MB
|
Id soluție | #52988846 | Utilizator | |
Fișier | moderat.cpp | Dimensiune | 1.49 KB |
Data încărcării | 15 Octombrie 2024, 07:50 | Scor / rezultat | Eroare de compilare |
moderat.cpp: In function 'void generatePrimes(int, int*, int&)': moderat.cpp:13:24: error: no matching function for call to 'begin(bool [(((sizetype)((ssizetype)limit)) + 1)])' fill(begin(is_prime), end(is_prime), true); ^ moderat.cpp:13:24: note: candidates are: In file included from /usr/include/c++/4.8/string:51: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 moderat.cpp:1: /usr/include/c++/4.8/bits/range_access.h:48:5: note: template<class _Container> decltype (__cont.begin()) std::begin(_Container&) begin(_Container& __cont) -> decltype(__cont.begin()) ^ /usr/include/c++/4.8/bits/range_access.h:48:5: note: template argument deduction/substitution failed: moderat.cpp:13:24: note: variable-sized array type 'bool [(((sizetype)((ssizetype)limit)) + 1)]' is not a valid template argument fill(begin(is_prime), end(is_prime), true); ^ In file included from /usr/include/c++/4.8/string:51: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 moderat.cpp:1: /usr/include/c++/4.8/bits/range_access.h:58:5: note: template<class _Container> decltype (__cont.begin()) std::begin(const _Container&) begin(const _Container& __cont) -> decltype(__cont.begin()) ^ /usr/include/c++/4.8/bits/range_access.h:58:5: note: template argument deduction/substitution failed: moderat.cpp:13:24: note: variable-sized array type 'bool [(((sizetype)((ssizetype)limit)) + 1)]' is not a valid template argument fill(begin(is_prime), end(is_prime), true); ^ In file included from /usr/include/c++/4.8/string:51: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 moderat.cpp:1: /usr/include/c++/4.8/bits/range_access.h:87:5: note: template<class _Tp, unsigned int _Nm> _Tp* std::begin(_Tp (&)[_Nm]) begin(_Tp (&__arr)[_Nm]) ^ /usr/include/c++/4.8/bits/range_access.h:87:5: note: template argument deduction/substitution failed: moderat.cpp:13:24: note: variable-sized array type 'bool [(((sizetype)((ssizetype)limit)) + 1)]' is not a valid template argument fill(begin(is_prime), end(is_prime), true); ^ In file included from /usr/include/c++/4.8/bits/basic_string.h:42:0, from /usr/include/c++/4.8/string:52, 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 moderat.cpp:1: /usr/include/c++/4.8/initializer_list:89:5: note: template<class _Tp> constexpr const _Tp* std::begin(std::initializer_list<_Tp>) begin(initializer_list<_Tp> __ils) noexcept ^ /usr/include/c++/4.8/initializer_list:89:5: note: template argument deduction/substitution failed: moderat.cpp:13:24: note: mismatched types 'std::initializer_list<_Tp>' and 'bool*' fill(begin(is_prime), end(is_prime), true); ^ moderat.cpp:13:39: error: no matching function for call to 'end(bool [(((sizetype)((ssizetype)limit)) + 1)])' fill(begin(is_prime), end(is_prime), true); ^ moderat.cpp:13:39: note: candidates are: In file included from /usr/include/c++/4.8/string:51: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 moderat.cpp:1: /usr/include/c++/4.8/bits/range_access.h:68:5: note: template<class _Container> decltype (__cont.end()) std::end(_Container&) end(_Container& __cont) -> decltype(__cont.end()) ^ /usr/include/c++/4.8/bits/range_access.h:68:5: note: template argument deduction/substitution failed: moderat.cpp:13:39: note: variable-sized array type 'bool [(((sizetype)((ssizetype)limit)) + 1)]' is not a valid template argument fill(begin(is_prime), end(is_prime), true); ^ In file included from /usr/include/c++/4.8/string:51: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 moderat.cpp:1: /usr/include/c++/4.8/bits/range_access.h:78:5: note: template<class _Container> decltype (__cont.end()) std::end(const _Container&) end(const _Container& __cont) -> decltype(__cont.end()) ^ /usr/include/c++/4.8/bits/range_access.h:78:5: note: template argument deduction/substitution failed: moderat.cpp:13:39: note: variable-sized array type 'bool [(((sizetype)((ssizetype)limit)) + 1)]' is not a valid template argument fill(begin(is_prime), end(is_prime), true); ^ In file included from /usr/include/c++/4.8/string:51: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 moderat.cpp:1: /usr/include/c++/4.8/bits/range_access.h:97:5: note: template<class _Tp, unsigned int _Nm> _Tp* std::end(_Tp (&)[_Nm]) end(_Tp (&__arr)[_Nm]) ^ /usr/include/c++/4.8/bits/range_access.h:97:5: note: template argument deduction/substitution failed: moderat.cpp:13:39: note: variable-sized array type 'bool [(((sizetype)((ssizetype)limit)) + 1)]' is not a valid template argument fill(begin(is_prime), end(is_prime), true); ^ In file included from /usr/include/c++/4.8/bits/basic_string.h:42:0, from /usr/include/c++/4.8/string:52, 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 moderat.cpp:1: /usr/include/c++/4.8/initializer_list:99:5: note: template<class _Tp> constexpr const _Tp* std::end(std::initializer_list<_Tp>) end(initializer_list<_Tp> __ils) noexcept ^ /usr/include/c++/4.8/initializer_list:99:5: note: template argument deduction/substitution failed: moderat.cpp:13:39: note: mismatched types 'std::initializer_list<_Tp>' and 'bool*' fill(begin(is_prime), end(is_prime), true); ^ moderat.cpp: In function 'int main()': moderat.cpp:69:5: error: redefinition of 'int main()' int main() ^ moderat.cpp:57:5: error: 'int main()' previously defined here int main() { ^ moderat.cpp:75:26: error: 'Moderat' was not declared in this scope fout << Moderat(n); ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema moderat face parte din a doua categorie. Pentru aceste probleme se folosește un program suport, furnizat de propunătorul problemei. 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ă.