#2202
extindere
Se consideră operația
: {1; 2} → {1; 2}
, astfel încât 1
= 2
, 2
= 1
. Operația se extinde asupra oricărei secvențe formate cu cifre de 1
și 2
, de exemplu 1211212121
=2122121212
.
Se consideră șirul infinit s
format cu cifre de 1
și 2
, generat incremental prin extindere după următoarea regulă de concatenare:
s1 = 1221
, s2 = 1221211221121221
, … , sk+1 = sk
sk sk
sk
, …, pentru orice număr natural nenul k
.
Să se scrie un program care pentru un n
număr natural nenul cunoscut determină și afișează a n
-a cifră a șirului s
, astfel încât numărul de pași ai programului să fie proporțional cu log2(n)
(complexitate timp logaritmică în funcție de n
).
Admitere FMI Bucuresti - 2014
Problema | extindere | Operații I/O |
extindere.in /extindere.out
|
---|---|---|---|
Limita timp | 0.01 secunde | Limita memorie |
Total: 0.1 MB
/
Stivă 0.1 MB
|
Id soluție | #7894046 | Utilizator | |
Fișier | extindere.cpp | Dimensiune | 2.57 KB |
Data încărcării | 18 Ianuarie 2018, 14:10 | Scor / rezultat | Eroare de compilare |
extindere.cpp:58:1: error: 'Mai' does not name a type Mai jos ai si codul de generare al sirului: ^ In file included from /usr/include/c++/4.8/fstream:936:0, from extindere.cpp:60: /usr/include/c++/4.8/bits/fstream.tcc: In member function 'virtual std::basic_filebuf<_CharT, _Traits>::int_type std::basic_filebuf<_CharT, _Traits>::underflow()': /usr/include/c++/4.8/bits/fstream.tcc:232:4: error: incomplete type 'std::codecvt_base' used in nested name specifier codecvt_base::result __r = codecvt_base::ok; ^ /usr/include/c++/4.8/bits/fstream.tcc:232:25: error: expected ';' before '__r' codecvt_base::result __r = codecvt_base::ok; ^ /usr/include/c++/4.8/bits/fstream.tcc:304:7: error: '__r' was not declared in this scope __r = _M_codecvt->in(_M_state_cur, _M_ext_next, ^ /usr/include/c++/4.8/bits/fstream.tcc:308:9: error: '__r' was not declared in this scope if (__r == codecvt_base::noconv) ^ /usr/include/c++/4.8/bits/fstream.tcc:308:16: error: incomplete type 'std::codecvt_base' used in nested name specifier if (__r == codecvt_base::noconv) ^ /usr/include/c++/4.8/bits/fstream.tcc:323:9: error: '__r' was not declared in this scope if (__r == codecvt_base::error) ^ /usr/include/c++/4.8/bits/fstream.tcc:323:16: error: incomplete type 'std::codecvt_base' used in nested name specifier if (__r == codecvt_base::error) ^ /usr/include/c++/4.8/bits/fstream.tcc:346:12: error: '__r' was not declared in this scope if (__r == codecvt_base::partial) ^ /usr/include/c++/4.8/bits/fstream.tcc:346:19: error: incomplete type 'std::codecvt_base' used in nested name specifier if (__r == codecvt_base::partial) ^ /usr/include/c++/4.8/bits/fstream.tcc:350:13: error: '__r' was not declared in this scope else if (__r == codecvt_base::error) ^ /usr/include/c++/4.8/bits/fstream.tcc:350:20: error: incomplete type 'std::codecvt_base' used in nested name specifier else if (__r == codecvt_base::error) ^ /usr/include/c++/4.8/bits/fstream.tcc: In member function 'bool std::basic_filebuf<_CharT, _Traits>::_M_convert_to_external(_CharT*, std::streamsize)': /usr/include/c++/4.8/bits/fstream.tcc:505:4: error: incomplete type 'std::codecvt_base' used in nested name specifier codecvt_base::result __r; ^ /usr/include/c++/4.8/bits/fstream.tcc:505:25: error: expected ';' before '__r' codecvt_base::result __r; ^ /usr/include/c++/4.8/bits/fstream.tcc:506:4: error: '__r' was not declared in this scope __r = _M_codecvt->out(_M_state_cur, __ibuf, __ibuf + __ilen, ^ /usr/include/c++/4.8/bits/fstream.tcc:509:15: error: incomplete type 'std::codecvt_base' used in nested name specifier if (__r == codecvt_base::ok || __r == codecvt_base::partial) ^ /usr/include/c++/4.8/bits/fstream.tcc:509:42: error: incomplete type 'std::codecvt_base' used in nested name specifier if (__r == codecvt_base::ok || __r == codecvt_base::partial) ^ /usr/include/c++/4.8/bits/fstream.tcc:511:20: error: incomplete type 'std::codecvt_base' used in nested name specifier else if (__r == codecvt_base::noconv) ^ /usr/include/c++/4.8/bits/fstream.tcc:525:15: error: incomplete type 'std::codecvt_base' used in nested name specifier if (__r == codecvt_base::partial && __elen == __plen) ^ /usr/include/c++/4.8/bits/fstream.tcc:532:19: error: incomplete type 'std::codecvt_base' used in nested name specifier if (__r != codecvt_base::error) ^ /usr/include/c++/4.8/bits/fstream.tcc: In member function 'bool std::basic_filebuf<_CharT, _Traits>::_M_terminate_output()': /usr/include/c++/4.8/bits/fstream.tcc:852:4: error: incomplete type 'std::codecvt_base' used in nested name specifier codecvt_base::result __r; ^ /usr/include/c++/4.8/bits/fstream.tcc:852:25: error: expected ';' before '__r' codecvt_base::result __r; ^ /usr/include/c++/4.8/bits/fstream.tcc:858:8: error: '__r' was not declared in this scope __r = _M_codecvt->unshift(_M_state_cur, __buf, ^ /usr/include/c++/4.8/bits/fstream.tcc:860:19: error: incomplete type 'std::codecvt_base' used in nested name specifier if (__r == codecvt_base::error) ^ /usr/include/c++/4.8/bits/fstream.tcc:862:24: error: incomplete type 'std::codecvt_base' used in nested name specifier else if (__r == codecvt_base::ok || ^ /usr/include/c++/4.8/bits/fstream.tcc:863:17: error: incomplete type 'std::codecvt_base' used in nested name specifier __r == codecvt_base::partial) ^ /usr/include/c++/4.8/bits/fstream.tcc:874:11: error: '__r' was not declared in this scope while (__r == codecvt_base::partial && __ilen > 0 && __testvalid); ^ /usr/include/c++/4.8/bits/fstream.tcc:874:18: error: incomplete type 'std::codecvt_base' used in nested name specifier while (__r == codecvt_base::partial && __ilen > 0 && __testvalid); ^ extindere.cpp: In function 'std::string neaga_sir(std::string)': extindere.cpp:70:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for(c=0;c<s.length();c++){ ^ extindere.cpp: In function 'int main()': extindere.cpp:143:5: error: redefinition of 'int main()' int main(){ ^ extindere.cpp:51:5: error: 'int main()' previously defined here int main(){ ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema extindere 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ă.