#874
Într-o galaxie îndepărtată există doar două elemente chimice. Cercetătorii le-au numit A şi B şi toate substanţele sunt alcătuite din aceste elemente. Mai precis, o substanţă este un şir definit astfel:
A şi B sunt substanţe, formate din câte un atom;Ax şi By sunt substanţe, x şi y find numere naturale. Ax este formată din x atomi de tip A, iar By este formată din y atomi de tip B;S este substanţă atunci (S)x este substanţă, x fiind un număr natural. Dacă în S sunt p atomi, în (S)x vor fin p*x atomi;S şi T sunt substanţe atunci ST este substanţă. Dacă în S sunt x atomi, iar în T sunt y atomi, în ST vor fi x+y atomi.Pentru o substanţă dată să se determine numărul atomilor de tip A şi numărul atomilor de tip B care o compun.
| Problema | Atomi | Operații I/O |
tastatură/ecran
|
|---|---|---|---|
| Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
| Id soluție | #64467462 | Utilizator | |
| Fișier | atomi.cpp | Dimensiune | 2.55 KB |
| Data încărcării | 08 Mai 2026, 13:45 | Scor/rezultat | 100 puncte |
atomi.cpp: In function ‘void get_num(long long unsigned int&, int&)’: atomi.cpp:14:32: warning: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Wsign-compare] 14 | while(isdigit(s[it]) && it < strlen(s)){ | ~~~^~~~~~~~~~~ atomi.cpp: In function ‘void get_var()’: atomi.cpp:23:22: warning: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Wsign-compare] 23 | for(int i = 0; i < strlen(s); i++){ | ~~^~~~~~~~~~~ atomi.cpp: In function ‘std::pair<long long unsigned int, long long unsigned int> eval(int&)’: atomi.cpp:43:14: warning: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Wsign-compare] 43 | while(it < strlen(s) && s[it] != ')'){ | ~~~^~~~~~~~~~~ atomi.cpp:53:19: warning: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Wsign-compare] 53 | if(it == strlen(s) || !isdigit(s[it + 1])) | ~~~^~~~~~~~~~~~ atomi.cpp:72:11: warning: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Wsign-compare] 72 | if(it < strlen(s) && isdigit(s[it])) | ~~~^~~~~~~~~~~ atomi.cpp: In function ‘void solve()’: atomi.cpp:89:14: warning: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Wsign-compare] 89 | while(it < strlen(s)){ | ~~~^~~~~~~~~~~ atomi.cpp:105:19: warning: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Wsign-compare] 105 | if(it == strlen(s) || !isdigit(s[it + 1])) | ~~~^~~~~~~~~~~~
| Test | Timp | Mesaj evaluare | Scor posibil | Scor obținut | ||
|---|---|---|---|---|---|---|
| 1 | 0.002 secunde | OK. | 20 | 20 | Exemplu | |
| 2 | 0.002 secunde | OK. | 20 | 20 | ||
| 3 | 0.001 secunde | OK. | 20 | 20 | ||
| 4 | 0.002 secunde | OK. | 20 | 20 | ||
| 5 | 0.002 secunde | OK. | 20 | 20 | ||
| Punctaj total | 100 | |||||
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema Atomi 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ă.