#3271
Se dă un șir de n
perechi de numere naturale nenule. Să se determine perechea pentru care cel mai mare divizor comun este maxim. Dacă există mai multe asemenea perechi, se va determina aceea pentru care suma valorilor este maximă. Exista mai multe asemenea perechi, se va determina prima din șir.
Problema | PerecheCMMDC | Operații I/O |
![]() |
---|---|---|---|
Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
Id soluție | #57776791 | Utilizator | |
Fișier | perechecmmdc.cpp | Dimensiune | 721 B |
Data încărcării | 15 Aprilie 2025, 17:41 | Scor / rezultat | Eroare de compilare |
perechecmmdc.cpp:3:23: error: expected initializer before 'suma' int a,n,b,max=0, max suma=0,q=0,z=0,x,y,d,s; ^ perechecmmdc.cpp: In function 'int main()': perechecmmdc.cpp:15:10: error: 'x' was not declared in this scope x = a; ^ perechecmmdc.cpp:16:10: error: 'y' was not declared in this scope y = b; ^ perechecmmdc.cpp:21:13: error: 'r' was not declared in this scope r = x % y; ^ perechecmmdc.cpp:26:10: error: 'd' was not declared in this scope d = x; ^ perechecmmdc.cpp:27:10: error: 's' was not declared in this scope s = a + b; ^ perechecmmdc.cpp:29:16: error: reference to 'max' is ambiguous if(d > max) ^ perechecmmdc.cpp:3:12: note: candidates are: int max int a,n,b,max=0, max suma=0,q=0,z=0,x,y,d,s; ^ 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 perechecmmdc.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) ^ perechecmmdc.cpp:31:13: error: reference to 'max' is ambiguous max = d; ^ perechecmmdc.cpp:3:12: note: candidates are: int max int a,n,b,max=0, max suma=0,q=0,z=0,x,y,d,s; ^ 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 perechecmmdc.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) ^ perechecmmdc.cpp:32:13: error: reference to 'max' is ambiguous max suma = s; ^ perechecmmdc.cpp:3:12: note: candidates are: int max int a,n,b,max=0, max suma=0,q=0,z=0,x,y,d,s; ^ 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 perechecmmdc.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) ^ perechecmmdc.cpp:32:17: error: expected ';' before 'suma' max suma = s; ^ perechecmmdc.cpp:33:13: error: 'q' was not declared in this scope q = a; ^ perechecmmdc.cpp:34:13: error: 'z' was not declared in this scope z= b; ^ perechecmmdc.cpp:37:21: error: reference to 'max' is ambiguous if(d == max && s > max suma) ^ perechecmmdc.cpp:3:12: note: candidates are: int max int a,n,b,max=0, max suma=0,q=0,z=0,x,y,d,s; ^ 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 perechecmmdc.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) ^ perechecmmdc.cpp:37:32: error: reference to 'max' is ambiguous if(d == max && s > max suma) ^ perechecmmdc.cpp:3:12: note: candidates are: int max int a,n,b,max=0, max suma=0,q=0,z=0,x,y,d,s; ^ 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 perechecmmdc.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) ^ perechecmmdc.cpp:37:36: error: expected ')' before 'suma' if(d == max && s > max suma) ^ perechecmmdc.cpp:39:13: error: reference to 'max' is ambiguous max suma = s; ^ perechecmmdc.cpp:3:12: note: candidates are: int max int a,n,b,max=0, max suma=0,q=0,z=0,x,y,d,s; ^ 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 perechecmmdc.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) ^ perechecmmdc.cpp:39:17: error: expected ';' before 'suma' max suma = s; ^ perechecmmdc.cpp:40:13: error: 'q' was not declared in this scope q= a; ^ perechecmmdc.cpp:41:13: error: 'z' was not declared in this scope z = b; ^ perechecmmdc.cpp:45:13: error: 'q' was not declared in this scope cout << q<< " " << z; ^ perechecmmdc.cpp:45:24: error: 'z' was not declared in this scope cout << q<< " " << z; ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema PerecheCMMDC 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ă.