#874
Atomi
Î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 | #53474844 | Utilizator | |
Fișier | atomi.cpp | Dimensiune | 1.28 KB |
Data încărcării | 01 Noiembrie 2024, 18:50 | Scor / rezultat | Eroare de compilare |
atomi.cpp: In function 'int main()': atomi.cpp:30:31: error: no matching function for call to 'max(int, long long int&)' vfa[niv]+=max(1,nr); ^ atomi.cpp:30:31: note: candidates are: In file included from /usr/include/c++/4.8/bits/char_traits.h:39:0, from /usr/include/c++/4.8/ios:40, from /usr/include/c++/4.8/ostream:38, from /usr/include/c++/4.8/iostream:39, from atomi.cpp:1: /usr/include/c++/4.8/bits/stl_algobase.h:216:5: note: template<class _Tp> const _Tp& std::max(const _Tp&, const _Tp&) max(const _Tp& __a, const _Tp& __b) ^ /usr/include/c++/4.8/bits/stl_algobase.h:216:5: note: template argument deduction/substitution failed: atomi.cpp:30:31: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') vfa[niv]+=max(1,nr); ^ In file included from /usr/include/c++/4.8/bits/char_traits.h:39:0, from /usr/include/c++/4.8/ios:40, from /usr/include/c++/4.8/ostream:38, from /usr/include/c++/4.8/iostream:39, from atomi.cpp:1: /usr/include/c++/4.8/bits/stl_algobase.h:260:5: note: template<class _Tp, class _Compare> const _Tp& std::max(const _Tp&, const _Tp&, _Compare) max(const _Tp& __a, const _Tp& __b, _Compare __comp) ^ /usr/include/c++/4.8/bits/stl_algobase.h:260:5: note: template argument deduction/substitution failed: atomi.cpp:30:31: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') vfa[niv]+=max(1,nr); ^ atomi.cpp:40:31: error: no matching function for call to 'max(int, long long int&)' vfb[niv]+=max(1,nr); ^ atomi.cpp:40:31: note: candidates are: In file included from /usr/include/c++/4.8/bits/char_traits.h:39:0, from /usr/include/c++/4.8/ios:40, from /usr/include/c++/4.8/ostream:38, from /usr/include/c++/4.8/iostream:39, from atomi.cpp:1: /usr/include/c++/4.8/bits/stl_algobase.h:216:5: note: template<class _Tp> const _Tp& std::max(const _Tp&, const _Tp&) max(const _Tp& __a, const _Tp& __b) ^ /usr/include/c++/4.8/bits/stl_algobase.h:216:5: note: template argument deduction/substitution failed: atomi.cpp:40:31: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') vfb[niv]+=max(1,nr); ^ In file included from /usr/include/c++/4.8/bits/char_traits.h:39:0, from /usr/include/c++/4.8/ios:40, from /usr/include/c++/4.8/ostream:38, from /usr/include/c++/4.8/iostream:39, from atomi.cpp:1: /usr/include/c++/4.8/bits/stl_algobase.h:260:5: note: template<class _Tp, class _Compare> const _Tp& std::max(const _Tp&, const _Tp&, _Compare) max(const _Tp& __a, const _Tp& __b, _Compare __comp) ^ /usr/include/c++/4.8/bits/stl_algobase.h:260:5: note: template argument deduction/substitution failed: atomi.cpp:40:31: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') vfb[niv]+=max(1,nr); ^ atomi.cpp:50:43: error: no matching function for call to 'max(int, long long int&)' vfa[niv]+=(vfa[niv+1]*max(1,nr)); ^ atomi.cpp:50:43: note: candidates are: In file included from /usr/include/c++/4.8/bits/char_traits.h:39:0, from /usr/include/c++/4.8/ios:40, from /usr/include/c++/4.8/ostream:38, from /usr/include/c++/4.8/iostream:39, from atomi.cpp:1: /usr/include/c++/4.8/bits/stl_algobase.h:216:5: note: template<class _Tp> const _Tp& std::max(const _Tp&, const _Tp&) max(const _Tp& __a, const _Tp& __b) ^ /usr/include/c++/4.8/bits/stl_algobase.h:216:5: note: template argument deduction/substitution failed: atomi.cpp:50:43: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') vfa[niv]+=(vfa[niv+1]*max(1,nr)); ^ In file included from /usr/include/c++/4.8/bits/char_traits.h:39:0, from /usr/include/c++/4.8/ios:40, from /usr/include/c++/4.8/ostream:38, from /usr/include/c++/4.8/iostream:39, from atomi.cpp:1: /usr/include/c++/4.8/bits/stl_algobase.h:260:5: note: template<class _Tp, class _Compare> const _Tp& std::max(const _Tp&, const _Tp&, _Compare) max(const _Tp& __a, const _Tp& __b, _Compare __comp) ^ /usr/include/c++/4.8/bits/stl_algobase.h:260:5: note: template argument deduction/substitution failed: atomi.cpp:50:43: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') vfa[niv]+=(vfa[niv+1]*max(1,nr)); ^ atomi.cpp:51:43: error: no matching function for call to 'max(int, long long int&)' vfb[niv]+=(vfb[niv+1]*max(1,nr)); ^ atomi.cpp:51:43: note: candidates are: In file included from /usr/include/c++/4.8/bits/char_traits.h:39:0, from /usr/include/c++/4.8/ios:40, from /usr/include/c++/4.8/ostream:38, from /usr/include/c++/4.8/iostream:39, from atomi.cpp:1: /usr/include/c++/4.8/bits/stl_algobase.h:216:5: note: template<class _Tp> const _Tp& std::max(const _Tp&, const _Tp&) max(const _Tp& __a, const _Tp& __b) ^ /usr/include/c++/4.8/bits/stl_algobase.h:216:5: note: template argument deduction/substitution failed: atomi.cpp:51:43: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') vfb[niv]+=(vfb[niv+1]*max(1,nr)); ^ In file included from /usr/include/c++/4.8/bits/char_traits.h:39:0, from /usr/include/c++/4.8/ios:40, from /usr/include/c++/4.8/ostream:38, from /usr/include/c++/4.8/iostream:39, from atomi.cpp:1: /usr/include/c++/4.8/bits/stl_algobase.h:260:5: note: template<class _Tp, class _Compare> const _Tp& std::max(const _Tp&, const _Tp&, _Compare) max(const _Tp& __a, const _Tp& __b, _Compare __comp) ^ /usr/include/c++/4.8/bits/stl_algobase.h:260:5: note: template argument deduction/substitution failed: atomi.cpp:51:43: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') vfb[niv]+=(vfb[niv+1]*max(1,nr)); ^
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ă.