#4769
zaruri
Să considerăm n
zaruri, numerotate de la 1
la n
. La aruncarea celor n
zaruri obţinem o succesiune de n
numere naturale cuprinse între 1
și 6
. Suma unei aruncări va fi egală cu suma numerelor obţinute. Câte aruncări de n
zaruri au suma cuprinsă între st
și dr
? Scrieți un program ce calculează răspunsul pentru mai multe întrebări de forma celei de mai sus. Pentru că numărul de aruncări poate fi destul de mare, calculați răspunsul modulo 1.000.003
.
OMI 2025, clasele 11-12
Problema | zaruri | Operații I/O |
![]() zaruri.in /zaruri.out
|
---|---|---|---|
Limita timp | 1 secunde | Limita memorie |
Total: 16 MB
/
Stivă 2 MB
|
Id soluție | #57938925 | Utilizator | |
Fișier | zaruri.cpp | Dimensiune | 1.72 KB |
Data încărcării | 03 Mai 2025, 20:40 | Scor / rezultat | Eroare de compilare |
zaruri.cpp: In function 'int main()': zaruri.cpp:25:20: error: invalid use of incomplete type '__gnu_cxx::__alloc_traits<std::allocator<std::tuple<int, int, int> > >::value_type {aka class std::tuple<int, int, int>}' queries[i] = {n, st, dr}; ^ 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/ostream:38, from /usr/include/c++/4.8/iostream:39, from zaruri.cpp:1: /usr/include/c++/4.8/bits/stl_pair.h:83:11: error: declaration of '__gnu_cxx::__alloc_traits<std::allocator<std::tuple<int, int, int> > >::value_type {aka class std::tuple<int, int, int>}' class tuple; ^ zaruri.cpp:50:22: error: expected unqualified-id before '[' token for (const auto& [n, st, dr] : queries) { ^ zaruri.cpp:50:22: error: expected ';' before '[' token zaruri.cpp:50:23: error: 'n' was not declared in this scope for (const auto& [n, st, dr] : queries) { ^ zaruri.cpp:50:26: error: 'st' was not declared in this scope for (const auto& [n, st, dr] : queries) { ^ zaruri.cpp:50:30: error: 'dr' was not declared in this scope for (const auto& [n, st, dr] : queries) { ^ zaruri.cpp: In lambda function: zaruri.cpp:50:34: error: expected '{' before ':' token for (const auto& [n, st, dr] : queries) { ^ zaruri.cpp: In function 'int main()': zaruri.cpp:50:34: error: expected ';' before ':' token zaruri.cpp:50:34: error: expected primary-expression before ':' token zaruri.cpp:50:34: error: expected ')' before ':' token zaruri.cpp:50:34: error: expected primary-expression before ':' token zaruri.cpp:50:34: error: expected ';' before ':' token zaruri.cpp:65:1: error: expected '}' at end of input } ^ In file included from /usr/include/c++/4.8/vector:64:0, from zaruri.cpp:3: /usr/include/c++/4.8/bits/stl_vector.h: In instantiation of 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) [with _Tp = std::tuple<int, int, int>; _Alloc = std::allocator<std::tuple<int, int, int> >; std::vector<_Tp, _Alloc>::reference = std::tuple<int, int, int>&; std::vector<_Tp, _Alloc>::size_type = unsigned int]': zaruri.cpp:25:18: required from here /usr/include/c++/4.8/bits/stl_vector.h:771:41: error: invalid use of incomplete type 'class std::tuple<int, int, int>' { return *(this->_M_impl._M_start + __n); } ^ 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/ostream:38, from /usr/include/c++/4.8/iostream:39, from zaruri.cpp:1: /usr/include/c++/4.8/bits/stl_pair.h:83:11: error: declaration of 'class std::tuple<int, int, int>' class tuple; ^ In file included from /usr/include/c++/4.8/vector:64:0, from zaruri.cpp:3: /usr/include/c++/4.8/bits/stl_vector.h: In instantiation of 'std::_Vector_base<_Tp, _Alloc>::~_Vector_base() [with _Tp = std::tuple<int, int, int>; _Alloc = std::allocator<std::tuple<int, int, int> >]': /usr/include/c++/4.8/bits/stl_vector.h:270:23: required from 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>::size_type, const allocator_type&) [with _Tp = std::tuple<int, int, int>; _Alloc = std::allocator<std::tuple<int, int, int> >; std::vector<_Tp, _Alloc>::size_type = unsigned int; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<std::tuple<int, int, int> >]' zaruri.cpp:19:43: required from here /usr/include/c++/4.8/bits/stl_vector.h:161:9: error: invalid use of incomplete type 'class std::tuple<int, int, int>' - this->_M_impl._M_start); } ^ 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/ostream:38, from /usr/include/c++/4.8/iostream:39, from zaruri.cpp:1: /usr/include/c++/4.8/bits/stl_pair.h:83:11: error: declaration of 'class std::tuple<int, int, int>' class tuple; ^ In file included from /usr/include/c++/4.8/vector:64:0, from zaruri.cpp:3: /usr/include/c++/4.8/bits/stl_vector.h: In instantiation of 'void std::_Vector_base<_Tp, _Alloc>::_M_create_storage(std::size_t) [with _Tp = std::tuple<int, int, int>; _Alloc = std::allocator<std::tuple<int, int, int> >; std::size_t = unsigned int]': /usr/include/c++/4.8/bits/stl_vector.h:136:30: required from 'std::_Vector_base<_Tp, _Alloc>::_Vector_base(std::size_t, const allocator_type&) [with _Tp = std::tuple<int, int, int>; _Alloc = std::allocator<std::tuple<int, int, int> >; std::size_t = unsigned int; std::_Vector_base<_Tp, _Alloc>::allocator_type = std::allocator<std::tuple<int, int, int> >]' /usr/include/c++/4.8/bits/stl_vector.h:270:23: required from 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>::size_type, const allocator_type&) [with _Tp = std::tuple<int, int, int>; _Alloc = std::allocator<std::tuple<int, int, int> >; std::vector<_Tp, _Alloc>::size_type = unsigned int; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<std::tuple<int, int, int> >]' zaruri.cpp:19:43: required from here /usr/include/c++/4.8/bits/stl_vector.h:183:59: error: invalid use of incomplete type 'class std::tuple<int, int, int>' this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __n; ^ 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/ostream:38, from /usr/include/c++/4.8/iostream:39, from zaruri.cpp:1: /usr/include/c++/4.8/bits/stl_pair.h:83:11: error: declaration of 'class std::tuple<int, int, int>' class tuple; ^ In file included from /usr/include/c++/4.8/vector:62:0, from zaruri.cpp:3: /usr/include/c++/4.8/bits/stl_construct.h: In instantiation of 'void std::_Destroy(_ForwardIterator, _ForwardIterator) [with _ForwardIterator = std::tuple<int, int, int>*]': /usr/include/c++/4.8/bits/stl_construct.h:151:31: required from 'void std::_Destroy(_ForwardIterator, _ForwardIterator, std::allocator<_T2>&) [with _ForwardIterator = std::tuple<int, int, int>*; _Tp = std::tuple<int, int, int>]' /usr/include/c++/4.8/bits/stl_vector.h:416:30: required from 'std::vector<_Tp, _Alloc>::~vector() [with _Tp = std::tuple<int, int, int>; _Alloc = std::allocator<std::tuple<int, int, int> >]' zaruri.cpp:19:43: required from here /usr/include/c++/4.8/bits/stl_construct.h:127:27: error: invalid use of incomplete type '_Value_type {aka class std::tuple<int, int, int>}' __destroy(__first, __last); ^ 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/ostream:38, from /usr/include/c++/4.8/iostream:39, from zaruri.cpp:1: /usr/include/c++/4.8/bits/stl_pair.h:83:11: error: declaration of '_Value_type {aka class std::tuple<int, int, int>}' class tuple; ^ In file included from /usr/include/c++/4.8/vector:63:0, from zaruri.cpp:3: /usr/include/c++/4.8/bits/stl_uninitialized.h: In instantiation of 'void std::__uninitialized_default_n(_ForwardIterator, _Size) [with _ForwardIterator = std::tuple<int, int, int>*; _Size = unsigned int]': /usr/include/c++/4.8/bits/stl_uninitialized.h:605:50: required from 'void std::__uninitialized_default_n_a(_ForwardIterator, _Size, std::allocator<_Tp>&) [with _ForwardIterator = std::tuple<int, int, int>*; _Size = unsigned int; _Tp = std::tuple<int, int, int>]' /usr/include/c++/4.8/bits/stl_vector.h:1225:28: required from 'void std::vector<_Tp, _Alloc>::_M_default_initialize(std::vector<_Tp, _Alloc>::size_type) [with _Tp = std::tuple<int, int, int>; _Alloc = std::allocator<std::tuple<int, int, int> >; std::vector<_Tp, _Alloc>::size_type = unsigned int]' /usr/include/c++/4.8/bits/stl_vector.h:271:34: required from 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>::size_type, const allocator_type&) [with _Tp = std::tuple<int, int, int>; _Alloc = std::allocator<std::tuple<int, int, int> >; std::vector<_Tp, _Alloc>::size_type = unsigned int; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<std::tuple<int, int, int> >]' zaruri.cpp:19:43: required from here /usr/include/c++/4.8/bits/stl_uninitialized.h:544:33: error: invalid use of incomplete type '_ValueType {aka class std::tuple<int, int, int>}' __uninit_default_n(__first, __n); ^ 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/ostream:38, from /usr/include/c++/4.8/iostream:39, from zaruri.cpp:1: /usr/include/c++/4.8/bits/stl_pair.h:83:11: error: declaration of '_ValueType {aka class std::tuple<int, int, int>}' class tuple; ^ In file included from /usr/include/i386-linux-gnu/c++/4.8/bits/c++allocator.h:33:0, from /usr/include/c++/4.8/bits/allocator.h:46, from /usr/include/c++/4.8/string:41, 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/ostream:38, from /usr/include/c++/4.8/iostream:39, from zaruri.cpp:1: /usr/include/c++/4.8/ext/new_allocator.h: In instantiation of '_Tp* __gnu_cxx::new_allocator<_Tp>::allocate(__gnu_cxx::new_allocator<_Tp>::size_type, const void*) [with _Tp = std::tuple<int, int, int>; __gnu_cxx::new_allocator<_Tp>::pointer = std::tuple<int, int, int>*; __gnu_cxx::new_allocator<_Tp>::size_type = unsigned int]': /usr/include/c++/4.8/bits/stl_vector.h:168:25: required from 'std::_Vector_base<_Tp, _Alloc>::pointer std::_Vector_base<_Tp, _Alloc>::_M_allocate(std::size_t) [with _Tp = std::tuple<int, int, int>; _Alloc = std::allocator<std::tuple<int, int, int> >; std::_Vector_base<_Tp, _Alloc>::pointer = std::tuple<int, int, int>*; std::size_t = unsigned int]' /usr/include/c++/4.8/bits/stl_vector.h:181:25: required from 'void std::_Vector_base<_Tp, _Alloc>::_M_create_storage(std::size_t) [with _Tp = std::tuple<int, int, int>; _Alloc = std::allocator<std::tuple<int, int, int> >; std::size_t = unsigned int]' /usr/include/c++/4.8/bits/stl_vector.h:136:30: required from 'std::_Vector_base<_Tp, _Alloc>::_Vector_base(std::size_t, const allocator_type&) [with _Tp = std::tuple<int, int, int>; _Alloc = std::allocator<std::tuple<int, int, int> >; std::size_t = unsigned int; std::_Vector_base<_Tp, _Alloc>::allocator_type = std::allocator<std::tuple<int, int, int> >]' /usr/include/c++/4.8/bits/stl_vector.h:270:23: required from 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>::size_type, const allocator_type&) [with _Tp = std::tuple<int, int, int>; _Alloc = std::allocator<std::tuple<int, int, int> >; std::vector<_Tp, _Alloc>::size_type = unsigned int; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<std::tuple<int, int, int> >]' zaruri.cpp:19:43: required from here /usr/include/c++/4.8/ext/new_allocator.h:104:54: error: invalid application of 'sizeof' to incomplete type 'std::tuple<int, int, int>' return static_cast<_Tp*>(::operator new(__n * sizeof(_Tp))); ^ /usr/include/c++/4.8/ext/new_allocator.h: In instantiation of '__gnu_cxx::new_allocator<_Tp>::size_type __gnu_cxx::new_allocator<_Tp>::max_size() const [with _Tp = std::tuple<int, int, int>; __gnu_cxx::new_allocator<_Tp>::size_type = unsigned int]': /usr/include/c++/4.8/ext/new_allocator.h:101:10: required from '_Tp* __gnu_cxx::new_allocator<_Tp>::allocate(__gnu_cxx::new_allocator<_Tp>::size_type, const void*) [with _Tp = std::tuple<int, int, int>; __gnu_cxx::new_allocator<_Tp>::pointer = std::tuple<int, int, int>*; __gnu_cxx::new_allocator<_Tp>::size_type = unsigned int]' /usr/include/c++/4.8/bits/stl_vector.h:168:25: required from 'std::_Vector_base<_Tp, _Alloc>::pointer std::_Vector_base<_Tp, _Alloc>::_M_allocate(std::size_t) [with _Tp = std::tuple<int, int, int>; _Alloc = std::allocator<std::tuple<int, int, int> >; std::_Vector_base<_Tp, _Alloc>::pointer = std::tuple<int, int, int>*; std::size_t = unsigned int]' /usr/include/c++/4.8/bits/stl_vector.h:181:25: required from 'void std::_Vector_base<_Tp, _Alloc>::_M_create_storage(std::size_t) [with _Tp = std::tuple<int, int, int>; _Alloc = std::allocator<std::tuple<int, int, int> >; std::size_t = unsigned int]' /usr/include/c++/4.8/bits/stl_vector.h:136:30: required from 'std::_Vector_base<_Tp, _Alloc>::_Vector_base(std::size_t, const allocator_type&) [with _Tp = std::tuple<int, int, int>; _Alloc = std::allocator<std::tuple<int, int, int> >; std::size_t = unsigned int; std::_Vector_base<_Tp, _Alloc>::allocator_type = std::allocator<std::tuple<int, int, int> >]' /usr/include/c++/4.8/bits/stl_vector.h:270:23: required from 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>::size_type, const allocator_type&) [with _Tp = std::tuple<int, int, int>; _Alloc = std::allocator<std::tuple<int, int, int> >; std::vector<_Tp, _Alloc>::size_type = unsigned int; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<std::tuple<int, int, int> >]' zaruri.cpp:19:43: required from here /usr/include/c++/4.8/ext/new_allocator.h:114:35: error: invalid application of 'sizeof' to incomplete type 'std::tuple<int, int, int>' { return size_t(-1) / sizeof(_Tp); } ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema zaruri 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ă.