#1044
Piramide
Fascinat de Egiptul Antic, Rareș vrea să construiască cât mai multe piramide din cartonașe pătratice identice. El are la dispoziție N
cartonașe numerotate de la 1
la N
, albe sau gri, așezate în ordinea strict crescătoare a numerelor.
1
și 2
așezate alăturat, peste care va așeza cartonașul 3
(vârful piramidei).4
, 5
și 6
așezate alăturat, deasupra cărora se vor așeza cartonașele 7
și 8
, alăturate, peste care se va așeza cartonașul 9
(vârful piramidei).4
cartonașe (cu numerele de la 10
la 13
), respectiv 5
cartonașe (cu numerele de la 20
la 24
), 6
cartonașe (cu numerele de la 35
la 40
) etc., cât timp va putea construi o piramidă completă. De exemplu, dacă Rareș are N=75
cartonașe atunci el va construi piramidele complete 1
, 2
, 3
, 4
și 5
din imaginile următoare. Din cele 75
de cartonașe el va folosi doar primele 55
de cartonașe, deoarece ultimele 20
cartonașe nu sunt suficiente pentru a construi piramida 6
, cu baza formată din 7
cartonașe.Scrieţi un program care să citească numerele naturale N
(reprezentând numărul de cartonașe), X
(reprezentând numărul unui cartonaș), K
(reprezentând numărul de cartonașe albe), numerele celor K
cartonașe albe c
1
, c
2
, …, c
K
și care să determine:
a) numărul P
al piramidei complete ce conține cartonașul numerotat cu X
;
b) numărul M
maxim de piramide complete construite de Rareș;
c) numărul C
de cartonașe nefolosite;
d) numărul A
al primei piramide complete care conține cele mai multe cartonașe albe.
OJI 2014, Clasa a V-a
Problema | Piramide | Operații I/O |
![]() piramide.in /piramide.out
|
---|---|---|---|
Limita timp | 0.5 secunde | Limita memorie |
Total: 2 MB
/
Stivă 2 MB
|
Id soluție | #50595803 | Utilizator | |
Fișier | piramide.cpp | Dimensiune | 962 B |
Data încărcării | 16 Aprilie 2024, 15:38 | Scor / rezultat | Eroare de compilare |
piramide.cpp: In function 'int main()': piramide.cpp:9:6: error: no match for 'operator>' (operand types are 'std::ifstream {aka std::basic_ifstream<char>}' and 'int') f>n>>x>>k; ^ piramide.cpp:9:6: note: candidates are: In file included from /usr/include/c++/4.8/bits/stl_algobase.h:64:0, from /usr/include/c++/4.8/bits/char_traits.h:39, 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 piramide.cpp:1: /usr/include/c++/4.8/bits/stl_pair.h:233:5: note: template<class _T1, class _T2> constexpr bool std::operator>(const std::pair<_T1, _T2>&, const std::pair<_T1, _T2>&) operator>(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) ^ /usr/include/c++/4.8/bits/stl_pair.h:233:5: note: template argument deduction/substitution failed: piramide.cpp:9:13: note: 'std::ifstream {aka std::basic_ifstream<char>}' is not derived from 'const std::pair<_T1, _T2>' f>n>>x>>k; ^ In file included from /usr/include/c++/4.8/bits/stl_algobase.h:67:0, from /usr/include/c++/4.8/bits/char_traits.h:39, 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 piramide.cpp:1: /usr/include/c++/4.8/bits/stl_iterator.h:309:5: note: template<class _Iterator> bool std::operator>(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_Iterator>&) operator>(const reverse_iterator<_Iterator>& __x, ^ /usr/include/c++/4.8/bits/stl_iterator.h:309:5: note: template argument deduction/substitution failed: piramide.cpp:9:13: note: 'std::ifstream {aka std::basic_ifstream<char>}' is not derived from 'const std::reverse_iterator<_Iterator>' f>n>>x>>k; ^ In file included from /usr/include/c++/4.8/bits/stl_algobase.h:67:0, from /usr/include/c++/4.8/bits/char_traits.h:39, 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 piramide.cpp:1: /usr/include/c++/4.8/bits/stl_iterator.h:359:5: note: template<class _IteratorL, class _IteratorR> bool std::operator>(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_IteratorR>&) operator>(const reverse_iterator<_IteratorL>& __x, ^ /usr/include/c++/4.8/bits/stl_iterator.h:359:5: note: template argument deduction/substitution failed: piramide.cpp:9:13: note: 'std::ifstream {aka std::basic_ifstream<char>}' is not derived from 'const std::reverse_iterator<_Iterator>' f>n>>x>>k; ^ In file included from /usr/include/c++/4.8/bits/stl_algobase.h:67:0, from /usr/include/c++/4.8/bits/char_traits.h:39, 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 piramide.cpp:1: /usr/include/c++/4.8/bits/stl_iterator.h:1079:5: note: template<class _IteratorL, class _IteratorR> bool std::operator>(const std::move_iterator<_Iterator>&, const std::move_iterator<_IteratorR>&) operator>(const move_iterator<_IteratorL>& __x, ^ /usr/include/c++/4.8/bits/stl_iterator.h:1079:5: note: template argument deduction/substitution failed: piramide.cpp:9:13: note: 'std::ifstream {aka std::basic_ifstream<char>}' is not derived from 'const std::move_iterator<_Iterator>' f>n>>x>>k; ^ In file included from /usr/include/c++/4.8/bits/stl_algobase.h:67:0, from /usr/include/c++/4.8/bits/char_traits.h:39, 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 piramide.cpp:1: /usr/include/c++/4.8/bits/stl_iterator.h:1085:5: note: template<class _Iterator> bool std::operator>(const std::move_iterator<_Iterator>&, const std::move_iterator<_Iterator>&) operator>(const move_iterator<_Iterator>& __x, ^ /usr/include/c++/4.8/bits/stl_iterator.h:1085:5: note: template argument deduction/substitution failed: piramide.cpp:9:13: note: 'std::ifstream {aka std::basic_ifstream<char>}' is not derived from 'const std::move_iterator<_Iterator>' f>n>>x>>k; ^ In file included from /usr/include/c++/4.8/string:52:0, from /usr/include/c++/4.8/bits/locale_classes.h:40, from /usr/include/c++/4.8/bits/ios_base.h:41, from /usr/include/c++/4.8/ios:42, from /usr/include/c++/4.8/istream:38, from /usr/include/c++/4.8/fstream:38, from piramide.cpp:1: /usr/include/c++/4.8/bits/basic_string.h:2606:5: note: template<class _CharT, class _Traits, class _Alloc> bool std::operator>(const std::basic_string<_CharT, _Traits, _Alloc>&, const std::basic_string<_CharT, _Traits, _Alloc>&) operator>(const basic_string<_CharT, _Traits, _Alloc>& __lhs, ^ /usr/include/c++/4.8/bits/basic_string.h:2606:5: note: template argument deduction/substitution failed: piramide.cpp:9:13: note: 'std::ifstream {aka std::basic_ifstream<char>}' is not derived from 'const std::basic_string<_CharT, _Traits, _Alloc>' f>n>>x>>k; ^ In file included from /usr/include/c++/4.8/string:52:0, from /usr/include/c++/4.8/bits/locale_classes.h:40, from /usr/include/c++/4.8/bits/ios_base.h:41, from /usr/include/c++/4.8/ios:42, from /usr/include/c++/4.8/istream:38, from /usr/include/c++/4.8/fstream:38, from piramide.cpp:1: /usr/include/c++/4.8/bits/basic_string.h:2618:5: note: template<class _CharT, class _Traits, class _Alloc> bool std::operator>(const std::basic_string<_CharT, _Traits, _Alloc>&, const _CharT*) operator>(const basic_string<_CharT, _Traits, _Alloc>& __lhs, ^ /usr/include/c++/4.8/bits/basic_string.h:2618:5: note: template argument deduction/substitution failed: piramide.cpp:9:13: note: 'std::ifstream {aka std::basic_ifstream<char>}' is not derived from 'const std::basic_string<_CharT, _Traits, _Alloc>' f>n>>x>>k; ^ In file included from /usr/include/c++/4.8/string:52:0, from /usr/include/c++/4.8/bits/locale_classes.h:40, from /usr/include/c++/4.8/bits/ios_base.h:41, from /usr/include/c++/4.8/ios:42, from /usr/include/c++/4.8/istream:38, from /usr/include/c++/4.8/fstream:38, from piramide.cpp:1: /usr/include/c++/4.8/bits/basic_string.h:2630:5: note: template<class _CharT, class _Traits, class _Alloc> bool std::operator>(const _CharT*, const std::basic_string<_CharT, _Traits, _Alloc>&) operator>(const _CharT* __lhs, ^ /usr/include/c++/4.8/bits/basic_string.h:2630:5: note: template argument deduction/substitution failed: piramide.cpp:9:13: note: mismatched types 'const _CharT*' and 'std::basic_ifstream<char>' f>n>>x>>k; ^ piramide.cpp:8:15: warning: unused variable 'cnt' [-Wunused-variable] int i=1,n,cnt=0,sb=0,x,j=1,sa,k,ck[100001],m,c=1,sd=0,maxi=0,pirmax; ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema Piramide 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ă.