#970
Gen
Pe planeta Marte, marţienii folosesc în calculele aritmetice doar cifrele 0
, 1
, 2
şi 3
. Ei au inventat un nou sistem binar de numeraţie. Pornind de la numărul 23
, ei generează numere binare speciale aplicând de un număr finit de ori regulile din tabelul de mai jos:
2
se poate înlocui cu succesiunea: 12
3
se poate înlocui cu succesiunea: 03
2
se poate înlocui cu succesiunea: 01
3
se poate înlocui cu succesiunea: 10
Marţienii au început să genereze un astfel de număr, aplicând succesiv (în această ordine): de n
ori regula 1); de k
ori regula 2); o singură dată regula 3) şi o singură dată regula 4). Nefiind atenţi, ei nu au reuşit să ducă la capăt generarea şi au nevoie de ajutor. Ajutaţi-i să genereze numărul binar dorit.
Scrieţi un program care citeşte numerele naturale nenule n
şi k
şi care afişează numărul binar obţinut în urma aplicării succesive a regulilor cerute de marţieni.
Olimpiada de Informatică, etapa pe sector, Bucureşti, 2007, clasa a VI-a
Problema | Gen | Operații I/O |
![]() |
---|---|---|---|
Limita timp | 1 secunde | Limita memorie |
Total: 2 MB
/
Stivă 1 MB
|
Id soluție | #51528405 | Utilizator | |
Fișier | gen.cpp | Dimensiune | 524 B |
Data încărcării | 05 Iulie 2024, 12:26 | Scor / rezultat | Eroare de compilare |
gen.cpp: In function 'int main()': gen.cpp:14:56: error: no matching function for call to 'regex_replace(std::string&, std::regex, const char [3])' number = regex_replace(number, regex("2"), "12"); ^ gen.cpp:14:56: note: candidates are: In file included from /usr/include/c++/4.8/regex:62:0, from gen.cpp:3: /usr/include/c++/4.8/bits/regex.h:2162:5: note: template<class _Out_iter, class _Bi_iter, class _Rx_traits, class _Ch_type> _Out_iter std::regex_replace(_Out_iter, _Bi_iter, _Bi_iter, const std::basic_regex<_Ch_type, _Rx_traits>&, const std::basic_string<_Ch_type>&, std::regex_constants::match_flag_type) regex_replace(_Out_iter __out, _Bi_iter __first, _Bi_iter __last, ^ /usr/include/c++/4.8/bits/regex.h:2162:5: note: template argument deduction/substitution failed: gen.cpp:14:56: note: deduced conflicting types for parameter '_Bi_iter' ('std::basic_regex<char>' and 'const char*') number = regex_replace(number, regex("2"), "12"); ^ In file included from /usr/include/c++/4.8/regex:62:0, from gen.cpp:3: /usr/include/c++/4.8/bits/regex.h:2182:5: note: template<class _Rx_traits, class _Ch_type> std::basic_string<_Ch_type> std::regex_replace(const std::basic_string<_Ch_type>&, const std::basic_regex<_Ch_type, _Rx_traits>&, const std::basic_string<_Ch_type>&, std::regex_constants::match_flag_type) regex_replace(const basic_string<_Ch_type>& __s, ^ /usr/include/c++/4.8/bits/regex.h:2182:5: note: template argument deduction/substitution failed: gen.cpp:14:56: note: mismatched types 'const std::basic_string<_Ch_type>' and 'const char [3]' number = regex_replace(number, regex("2"), "12"); ^ gen.cpp:18:56: error: no matching function for call to 'regex_replace(std::string&, std::regex, const char [3])' number = regex_replace(number, regex("3"), "03"); ^ gen.cpp:18:56: note: candidates are: In file included from /usr/include/c++/4.8/regex:62:0, from gen.cpp:3: /usr/include/c++/4.8/bits/regex.h:2162:5: note: template<class _Out_iter, class _Bi_iter, class _Rx_traits, class _Ch_type> _Out_iter std::regex_replace(_Out_iter, _Bi_iter, _Bi_iter, const std::basic_regex<_Ch_type, _Rx_traits>&, const std::basic_string<_Ch_type>&, std::regex_constants::match_flag_type) regex_replace(_Out_iter __out, _Bi_iter __first, _Bi_iter __last, ^ /usr/include/c++/4.8/bits/regex.h:2162:5: note: template argument deduction/substitution failed: gen.cpp:18:56: note: deduced conflicting types for parameter '_Bi_iter' ('std::basic_regex<char>' and 'const char*') number = regex_replace(number, regex("3"), "03"); ^ In file included from /usr/include/c++/4.8/regex:62:0, from gen.cpp:3: /usr/include/c++/4.8/bits/regex.h:2182:5: note: template<class _Rx_traits, class _Ch_type> std::basic_string<_Ch_type> std::regex_replace(const std::basic_string<_Ch_type>&, const std::basic_regex<_Ch_type, _Rx_traits>&, const std::basic_string<_Ch_type>&, std::regex_constants::match_flag_type) regex_replace(const basic_string<_Ch_type>& __s, ^ /usr/include/c++/4.8/bits/regex.h:2182:5: note: template argument deduction/substitution failed: gen.cpp:18:56: note: mismatched types 'const std::basic_string<_Ch_type>' and 'const char [3]' number = regex_replace(number, regex("3"), "03"); ^ gen.cpp:20:52: error: no matching function for call to 'regex_replace(std::string&, std::regex, const char [3])' number = regex_replace(number, regex("2"), "01"); ^ gen.cpp:20:52: note: candidates are: In file included from /usr/include/c++/4.8/regex:62:0, from gen.cpp:3: /usr/include/c++/4.8/bits/regex.h:2162:5: note: template<class _Out_iter, class _Bi_iter, class _Rx_traits, class _Ch_type> _Out_iter std::regex_replace(_Out_iter, _Bi_iter, _Bi_iter, const std::basic_regex<_Ch_type, _Rx_traits>&, const std::basic_string<_Ch_type>&, std::regex_constants::match_flag_type) regex_replace(_Out_iter __out, _Bi_iter __first, _Bi_iter __last, ^ /usr/include/c++/4.8/bits/regex.h:2162:5: note: template argument deduction/substitution failed: gen.cpp:20:52: note: deduced conflicting types for parameter '_Bi_iter' ('std::basic_regex<char>' and 'const char*') number = regex_replace(number, regex("2"), "01"); ^ In file included from /usr/include/c++/4.8/regex:62:0, from gen.cpp:3: /usr/include/c++/4.8/bits/regex.h:2182:5: note: template<class _Rx_traits, class _Ch_type> std::basic_string<_Ch_type> std::regex_replace(const std::basic_string<_Ch_type>&, const std::basic_regex<_Ch_type, _Rx_traits>&, const std::basic_string<_Ch_type>&, std::regex_constants::match_flag_type) regex_replace(const basic_string<_Ch_type>& __s, ^ /usr/include/c++/4.8/bits/regex.h:2182:5: note: template argument deduction/substitution failed: gen.cpp:20:52: note: mismatched types 'const std::basic_string<_Ch_type>' and 'const char [3]' number = regex_replace(number, regex("2"), "01"); ^ gen.cpp:21:52: error: no matching function for call to 'regex_replace(std::string&, std::regex, const char [3])' number = regex_replace(number, regex("3"), "10"); ^ gen.cpp:21:52: note: candidates are: In file included from /usr/include/c++/4.8/regex:62:0, from gen.cpp:3: /usr/include/c++/4.8/bits/regex.h:2162:5: note: template<class _Out_iter, class _Bi_iter, class _Rx_traits, class _Ch_type> _Out_iter std::regex_replace(_Out_iter, _Bi_iter, _Bi_iter, const std::basic_regex<_Ch_type, _Rx_traits>&, const std::basic_string<_Ch_type>&, std::regex_constants::match_flag_type) regex_replace(_Out_iter __out, _Bi_iter __first, _Bi_iter __last, ^ /usr/include/c++/4.8/bits/regex.h:2162:5: note: template argument deduction/substitution failed: gen.cpp:21:52: note: deduced conflicting types for parameter '_Bi_iter' ('std::basic_regex<char>' and 'const char*') number = regex_replace(number, regex("3"), "10"); ^ In file included from /usr/include/c++/4.8/regex:62:0, from gen.cpp:3: /usr/include/c++/4.8/bits/regex.h:2182:5: note: template<class _Rx_traits, class _Ch_type> std::basic_string<_Ch_type> std::regex_replace(const std::basic_string<_Ch_type>&, const std::basic_regex<_Ch_type, _Rx_traits>&, const std::basic_string<_Ch_type>&, std::regex_constants::match_flag_type) regex_replace(const basic_string<_Ch_type>& __s, ^ /usr/include/c++/4.8/bits/regex.h:2182:5: note: template argument deduction/substitution failed: gen.cpp:21:52: note: mismatched types 'const std::basic_string<_Ch_type>' and 'const char [3]' number = regex_replace(number, regex("3"), "10"); ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema Gen 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ă.