#3038
Aflat într-o vizită cu părinții, Iliuță primește un bilet la tombolă pe care este scris un număr natural S. Pentru a câștiga un premiu, Iliuță trebuie să afle, plecând de la numărul S, un număr câștigător X. Pentru a-l ajuta să ghicească numărul câștigător, mama îi spune lui Iliuță că numărul S de pe biletul său este suma dintre numărul câștigător X și toate numerele obținute plecând de la numărul câștigător X, prin ștergerea cifrei unităților numărului X, apoi, succesiv, prin ștergerea cifrei unităților numărului obținut la pasul anterior, până se ajunge la un număr de o singură cifră.
Cunoscându-se numerele naturale N, S1, A, B, C, D, scrieți un program care rezolvă următoarele cerințe:
1) pentru fiecare dintre termenii șirului S1, S2, …, SN, determină cel mai mare număr natural mai mic strict decât termenul respectiv, pentru care există un număr câștigător; programul va afișa restul împărțirii sumei numerelor obținute la 1018+31;
2) pentru fiecare dintre termenii șirului S1, S2, …, SN, determină câte numere naturale mai mici sau egale cu termenul respectiv NU au număr câștigător; programul va afișa restul împărțirii sumei rezultatelor obținute la 1018+31.
| Problema | tombola | Operații I/O |
tombola.in/tombola.out
|
|---|---|---|---|
| Limita timp | 1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 64 MB
|
| Id soluție | #58731834 | Utilizator | |
| Fișier | tombola.cpp | Dimensiune | 3.81 KB |
| Data încărcării | 27 Iulie 2025, 19:20 | Scor/rezultat | Eroare de compilare |
tombola.cpp:8:16: error: expected type-specifier before '__int128_t' using int128 = __int128_t; ^ tombola.cpp:11:13: error: 'int128' was not declared in this scope std::vector<int128> C_coeffs; // C_coeffs[i] = 1...1 (i+1 cifre) ^ tombola.cpp:11:19: error: template argument 1 is invalid std::vector<int128> C_coeffs; // C_coeffs[i] = 1...1 (i+1 cifre) ^ tombola.cpp:11:19: error: template argument 2 is invalid tombola.cpp:11:29: error: invalid type in declaration before ';' token std::vector<int128> C_coeffs; // C_coeffs[i] = 1...1 (i+1 cifre) ^ tombola.cpp:12:13: error: 'int128' was not declared in this scope std::vector<int128> P10; // P10[i] = 10^i ^ tombola.cpp:12:19: error: template argument 1 is invalid std::vector<int128> P10; // P10[i] = 10^i ^ tombola.cpp:12:19: error: template argument 2 is invalid tombola.cpp:12:24: error: invalid type in declaration before ';' token std::vector<int128> P10; // P10[i] = 10^i ^ tombola.cpp:16:44: error: 'int128' has not been declared std::ostream& operator<<(std::ostream& os, int128 val) { ^ tombola.cpp:31:44: error: 'int128' has not been declared std::istream& operator>>(std::istream& is, int128& val) { ^ tombola.cpp: In function 'void precompute()': tombola.cpp:50:14: error: request for member 'resize' in 'C_coeffs', which is of non-class type 'int' C_coeffs.resize(MAX_DIGITS); ^ tombola.cpp:51:9: error: request for member 'resize' in 'P10', which is of non-class type 'int' P10.resize(MAX_DIGITS); ^ tombola.cpp:52:15: error: invalid types 'int[int]' for array subscript C_coeffs[0] = 1; ^ tombola.cpp:53:10: error: invalid types 'int[int]' for array subscript P10[0] = 1; ^ tombola.cpp:55:19: error: invalid types 'int[int]' for array subscript C_coeffs[i] = C_coeffs[i - 1] * 10 + 1; ^ tombola.cpp:55:37: error: invalid types 'int[int]' for array subscript C_coeffs[i] = C_coeffs[i - 1] * 10 + 1; ^ tombola.cpp:56:14: error: invalid types 'int[int]' for array subscript P10[i] = P10[i - 1] * 10; ^ tombola.cpp:56:27: error: invalid types 'int[int]' for array subscript P10[i] = P10[i - 1] * 10; ^ tombola.cpp: At global scope: tombola.cpp:61:1: error: 'int128' does not name a type int128 calculate_Q(int128 x) { ^ tombola.cpp:72:1: error: 'int128' does not name a type int128 find_max_X(int128 S) { ^ tombola.cpp: In function 'int main()': tombola.cpp:101:9: error: ambiguous overload for 'operator>>' (operand types are 'std::ifstream {aka std::basic_ifstream<char>}' and 'int') fin >> p; ^ tombola.cpp:101:9: note: candidates are: In file included from /usr/include/c++/4.8/iostream:40:0, from tombola.cpp:1: /usr/include/c++/4.8/istream:120:7: note: std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_istream<_CharT, _Traits>::__istream_type& (*)(std::basic_istream<_CharT, _Traits>::__istream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>] <near match> operator>>(__istream_type& (*__pf)(__istream_type&)) ^ /usr/include/c++/4.8/istream:120:7: note: no known conversion for argument 1 from 'int' to 'std::basic_istream<char>::__istream_type& (*)(std::basic_istream<char>::__istream_type&) {aka std::basic_istream<char>& (*)(std::basic_istream<char>&)}' /usr/include/c++/4.8/istream:124:7: note: std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_istream<_CharT, _Traits>::__ios_type& (*)(std::basic_istream<_CharT, _Traits>::__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>; std::basic_istream<_CharT, _Traits>::__ios_type = std::basic_ios<char>] <near match> operator>>(__ios_type& (*__pf)(__ios_type&)) ^ /usr/include/c++/4.8/istream:124:7: note: no known conversion for argument 1 from 'int' to 'std::basic_istream<char>::__ios_type& (*)(std::basic_istream<char>::__ios_type&) {aka std::basic_ios<char>& (*)(std::basic_ios<char>&)}' /usr/include/c++/4.8/istream:131:7: note: std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(std::ios_base& (*)(std::ios_base&)) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>] <near match> operator>>(ios_base& (*__pf)(ios_base&)) ^ /usr/include/c++/4.8/istream:131:7: note: no known conversion for argument 1 from 'int' to 'std::ios_base& (*)(std::ios_base&)' /usr/include/c++/4.8/istream:179:7: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = char; _Traits = std::char_traits<char>] operator>>(int& __n); ^ /usr/include/c++/4.8/istream:259:7: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_istream<_CharT, _Traits>::__streambuf_type*) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__streambuf_type = std::basic_streambuf<char>] <near match> operator>>(__streambuf_type* __sb); ^ /usr/include/c++/4.8/istream:259:7: note: no known conversion for argument 1 from 'int' to 'std::basic_istream<char>::__streambuf_type* {aka std::basic_streambuf<char>*}' tombola.cpp:31:15: note: std::istream& operator>>(std::istream&, int&) std::istream& operator>>(std::istream& is, int128& val) { ^ In file included from /usr/include/c++/4.8/iostream:40:0, from tombola.cpp:1: /usr/include/c++/4.8/istream:872:5: note: std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&&, _Tp&) [with _CharT = char; _Traits = std::char_traits<char>; _Tp = int] <near match> operator>>(basic_istream<_CharT, _Traits>&& __is, _Tp& __x) ^ /usr/include/c++/4.8/istream:872:5: note: no known conversion for argument 1 from 'std::ifstream {aka std::basic_ifstream<char>}' to 'std::basic_istream<char>&&' tombola.cpp:104:5: error: 'int128' was not declared in this scope int128 S1, A, B, C_gen, D_gen; ^ tombola.cpp:104:12: error: expected ';' before 'S1' int128 S1, A, B, C_gen, D_gen; ^ tombola.cpp:106:17: error: 'S1' was not declared in this scope fin >> N >> S1 >> A >> B >> C_gen >> D_gen; ^ tombola.cpp:106:23: error: 'A' was not declared in this scope fin >> N >> S1 >> A >> B >> C_gen >> D_gen; ^ tombola.cpp:106:28: error: 'B' was not declared in this scope fin >> N >> S1 >> A >> B >> C_gen >> D_gen; ^ tombola.cpp:106:33: error: 'C_gen' was not declared in this scope fin >> N >> S1 >> A >> B >> C_gen >> D_gen; ^ tombola.cpp:106:42: error: 'D_gen' was not declared in this scope fin >> N >> S1 >> A >> B >> C_gen >> D_gen; ^ tombola.cpp:111:12: error: expected ';' before 'MOD' int128 MOD = 1; ^ tombola.cpp:113:9: error: 'MOD' was not declared in this scope MOD *= 10; ^ tombola.cpp:115:5: error: 'MOD' was not declared in this scope MOD += 31; ^ tombola.cpp:117:12: error: expected ';' before 'total_sum' int128 total_sum = 0; ^ tombola.cpp:118:12: error: expected ';' before 'current_S' int128 current_S = S1; ^ tombola.cpp:123:13: error: 'current_S' was not declared in this scope current_S = (current_S % A * B + C_gen) % D_gen; ^ tombola.cpp:127:20: error: expected ';' before 'target_S' int128 target_S = current_S - 1; ^ tombola.cpp:128:17: error: 'target_S' was not declared in this scope if (target_S > 0) { ^ tombola.cpp:129:24: error: expected ';' before 'X_found' int128 X_found = find_max_X(target_S); ^ tombola.cpp:130:24: error: expected ';' before 'Q_found' int128 Q_found = calculate_Q(X_found); ^ tombola.cpp:131:17: error: 'total_sum' was not declared in this scope total_sum += Q_found; ^ tombola.cpp:131:30: error: 'Q_found' was not declared in this scope total_sum += Q_found; ^ tombola.cpp:137:20: error: expected ';' before 'X_max' int128 X_max = find_max_X(current_S); ^ tombola.cpp:138:20: error: expected ';' before 'non_winning_count' int128 non_winning_count = current_S - X_max; ^ tombola.cpp:139:13: error: 'total_sum' was not declared in this scope total_sum += non_winning_count; ^ tombola.cpp:139:26: error: 'non_winning_count' was not declared in this scope total_sum += non_winning_count; ^ tombola.cpp:146:13: error: 'total_sum' was not declared in this scope fout << total_sum << std::endl; ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema tombola 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ă.