#4604
Macarie
Macarie a primit o nouă temă la informatică, având următorul enunț: Se consideră un șir de numere naturale nenule, A
cu N
elemente. Fie șirul crescător D
format din toți divizorii naturali, nu neapărat distincți, ai elementelor din A
. De exemplu, pentru N = 4
și A = (6,2,3,2)
, avem șirul D = (1,1,1,1,2,2,2,3,3,6)
. Cunoscându-se un șir Poz
format din Q
numere naturale nenule, reprezentând poziții din șirul D
să se determine, pentru fiecare dintre acestea, elementul corespunzător din șirul D
.
OJI 2024, clasa a 9-a
Problema | Macarie | Operații I/O |
macarie.in /macarie.out
|
---|---|---|---|
Limita timp | 0.4 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
Id soluție | #53123339 | Utilizator | |
Fișier | macarie.cpp | Dimensiune | 1.20 KB |
Data încărcării | 18 Octombrie 2024, 10:13 | Scor / rezultat | Eroare de compilare |
macarie.cpp: In function 'int cautare_binara(int, int*)': macarie.cpp:25:18: error: reference to 'max' is ambiguous int st=0, dr=max; ^ macarie.cpp:7:5: note: candidates are: int max int max; ^ 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/istream:38, from /usr/include/c++/4.8/fstream:38, from macarie.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:216:5: note: template<class _Tp> const _Tp& std::max(const _Tp&, const _Tp&) max(const _Tp& __a, const _Tp& __b) ^ macarie.cpp:27:13: error: reference to 'max' is ambiguous int poz=max+1, m; ^ macarie.cpp:7:5: note: candidates are: int max int max; ^ 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/istream:38, from /usr/include/c++/4.8/fstream:38, from macarie.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:216:5: note: template<class _Tp> const _Tp& std::max(const _Tp&, const _Tp&) max(const _Tp& __a, const _Tp& __b) ^ macarie.cpp:31:9: error: 'm' was not declared in this scope m=(st+dr)/2; ^ macarie.cpp: In function 'int main()': macarie.cpp:56:19: error: reference to 'max' is ambiguous if(v[i] > max) ^ macarie.cpp:7:5: note: candidates are: int max int max; ^ 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/istream:38, from /usr/include/c++/4.8/fstream:38, from macarie.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:216:5: note: template<class _Tp> const _Tp& std::max(const _Tp&, const _Tp&) max(const _Tp& __a, const _Tp& __b) ^ macarie.cpp:57:13: error: reference to 'max' is ambiguous max = v[i]; ^ macarie.cpp:7:5: note: candidates are: int max int max; ^ 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/istream:38, from /usr/include/c++/4.8/fstream:38, from macarie.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:216:5: note: template<class _Tp> const _Tp& std::max(const _Tp&, const _Tp&) max(const _Tp& __a, const _Tp& __b) ^ macarie.cpp:63:14: error: reference to 'max' is ambiguous int suma[max+1]={0}; ^ macarie.cpp:7:5: note: candidates are: int max int max; ^ 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/istream:38, from /usr/include/c++/4.8/fstream:38, from macarie.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:216:5: note: template<class _Tp> const _Tp& std::max(const _Tp&, const _Tp&) max(const _Tp& __a, const _Tp& __b) ^ macarie.cpp:66:20: error: 'suma' was not declared in this scope divi(v[i], suma); ^ macarie.cpp:68:21: error: reference to 'max' is ambiguous for(int i=1; i<=max; i++) ^ macarie.cpp:7:5: note: candidates are: int max int max; ^ 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/istream:38, from /usr/include/c++/4.8/fstream:38, from macarie.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:216:5: note: template<class _Tp> const _Tp& std::max(const _Tp&, const _Tp&) max(const _Tp& __a, const _Tp& __b) ^ macarie.cpp:69:9: error: 'suma' was not declared in this scope suma[i] = suma[i-1] + suma[i]; ^ macarie.cpp:73:38: error: 'suma' was not declared in this scope cout << cautare_binara(q[i], suma) << ' '; ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema Macarie 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ă.