#4785
Se consideră şirul crescător 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, ..., în care fiecare număr natural nenul i apare de 2i-1 ori. Elementele unei matrice A cu M linii şi N coloane au valori astfel încât, parcurgând matricea de sus în jos, pe linii, și de la stânga la dreapta pe fiecare linie, se obțin primii M x N termeni ai șirului precizat. O submatrice a lui A este definită de patru valori, l1, c1, l2, c2 şi este formată din elementele Ai,j cu proprietatea că l1 ≤ i ≤ l2 și c1 ≤ j ≤ c2. Determinaţi suma elementelor pentru fiecare dintre Q submatrice date ale lui A.
OJI 2025, clasa a 9-a
| Problema | summat | Operații I/O |
summat.in/summat.out
|
|---|---|---|---|
| Limita timp | 0.9 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
| Id soluție | #63476930 | Utilizator | |
| Fișier | summat.cpp | Dimensiune | 3.71 KB |
| Data încărcării | 04 Martie 2026, 23:39 | Scor/rezultat | Eroare de compilare |
summat.cpp:7:20: error: 'long long int y1 [60]' redeclared as different kind of symbol long long int y1[60], y2[60]; ^ In file included from /usr/include/features.h:374:0, from /usr/include/assert.h:35, from /usr/include/c++/4.8/cassert:43, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:33, from summat.cpp:1: /usr/include/i386-linux-gnu/bits/mathcalls.h:241:1: error: previous declaration of 'double y1(double)' __MATHCALL (y1,, (_Mdouble_)); ^ summat.cpp: In function 'int main()': summat.cpp:39:13: warning: pointer to a function used in arithmetic [-Wpointer-arith] y1[i]=a[i]%N; ^ summat.cpp:39:14: error: assignment of read-only location '*(y1 + ((sizetype)i))' y1[i]=a[i]%N; ^ summat.cpp:39:14: error: cannot convert 'long long int' to 'double(double)throw ()' in assignment summat.cpp:40:16: warning: pointer to a function used in arithmetic [-Wpointer-arith] if(y1[i]==0) y1[i]=N; ^ summat.cpp:40:26: warning: pointer to a function used in arithmetic [-Wpointer-arith] if(y1[i]==0) y1[i]=N; ^ summat.cpp:40:27: error: assignment of read-only location '*(y1 + ((sizetype)i))' if(y1[i]==0) y1[i]=N; ^ summat.cpp:40:27: error: cannot convert 'long long int' to 'double(double)throw ()' in assignment summat.cpp:116:39: warning: pointer to a function used in arithmetic [-Wpointer-arith] if(y2[v]<c1 or c2<y1[v]) ok=0; ^ summat.cpp:116:39: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] summat.cpp:119:60: warning: pointer to a function used in arithmetic [-Wpointer-arith] T+=1LL * v * (min(c2,y2[v])-max(c1,y1[v])+1); ^ summat.cpp:119:61: error: no matching function for call to 'max(long long int&, double (&)(double)throw ())' T+=1LL * v * (min(c2,y2[v])-max(c1,y1[v])+1); ^ summat.cpp:119:61: note: candidates are: 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/sstream:38, from /usr/include/c++/4.8/complex:45, from /usr/include/c++/4.8/ccomplex:38, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:52, from summat.cpp:1: /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) ^ /usr/include/c++/4.8/bits/stl_algobase.h:216:5: note: template argument deduction/substitution failed: summat.cpp:119:61: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'double(double)throw ()') T+=1LL * v * (min(c2,y2[v])-max(c1,y1[v])+1); ^ 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/sstream:38, from /usr/include/c++/4.8/complex:45, from /usr/include/c++/4.8/ccomplex:38, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:52, from summat.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:260:5: note: template argument deduction/substitution failed: summat.cpp:119:61: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'double(double)throw ()') T+=1LL * v * (min(c2,y2[v])-max(c1,y1[v])+1); ^ In file included from /usr/include/c++/4.8/algorithm:62:0, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:64, from summat.cpp:1: /usr/include/c++/4.8/bits/stl_algo.h:4231:5: note: template<class _Tp> _Tp std::max(std::initializer_list<_Tp>) max(initializer_list<_Tp> __l) ^ /usr/include/c++/4.8/bits/stl_algo.h:4231:5: note: template argument deduction/substitution failed: summat.cpp:119:61: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' T+=1LL * v * (min(c2,y2[v])-max(c1,y1[v])+1); ^ In file included from /usr/include/c++/4.8/algorithm:62:0, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:64, from summat.cpp:1: /usr/include/c++/4.8/bits/stl_algo.h:4236:5: note: template<class _Tp, class _Compare> _Tp std::max(std::initializer_list<_Tp>, _Compare) max(initializer_list<_Tp> __l, _Compare __comp) ^ /usr/include/c++/4.8/bits/stl_algo.h:4236:5: note: template argument deduction/substitution failed: summat.cpp:119:61: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' T+=1LL * v * (min(c2,y2[v])-max(c1,y1[v])+1); ^ summat.cpp:124:48: warning: pointer to a function used in arithmetic [-Wpointer-arith] x3=x1[v]; if(x1[v]==l1 && y1[v]>c2) x3++; if(l1>x3) x3=l1; ^ summat.cpp:124:50: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] x3=x1[v]; if(x1[v]==l1 && y1[v]>c2) x3++; if(l1>x3) x3=l1; ^ summat.cpp:130:55: warning: pointer to a function used in arithmetic [-Wpointer-arith] T += 1LL * v * (c2-max(c1,y1[v])+1); ^ summat.cpp:130:56: error: no matching function for call to 'max(long long int&, double (&)(double)throw ())' T += 1LL * v * (c2-max(c1,y1[v])+1); ^ summat.cpp:130:56: note: candidates are: 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/sstream:38, from /usr/include/c++/4.8/complex:45, from /usr/include/c++/4.8/ccomplex:38, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:52, from summat.cpp:1: /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) ^ /usr/include/c++/4.8/bits/stl_algobase.h:216:5: note: template argument deduction/substitution failed: summat.cpp:130:56: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'double(double)throw ()') T += 1LL * v * (c2-max(c1,y1[v])+1); ^ 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/sstream:38, from /usr/include/c++/4.8/complex:45, from /usr/include/c++/4.8/ccomplex:38, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:52, from summat.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:260:5: note: template argument deduction/substitution failed: summat.cpp:130:56: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'double(double)throw ()') T += 1LL * v * (c2-max(c1,y1[v])+1); ^ In file included from /usr/include/c++/4.8/algorithm:62:0, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:64, from summat.cpp:1: /usr/include/c++/4.8/bits/stl_algo.h:4231:5: note: template<class _Tp> _Tp std::max(std::initializer_list<_Tp>) max(initializer_list<_Tp> __l) ^ /usr/include/c++/4.8/bits/stl_algo.h:4231:5: note: template argument deduction/substitution failed: summat.cpp:130:56: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' T += 1LL * v * (c2-max(c1,y1[v])+1); ^ In file included from /usr/include/c++/4.8/algorithm:62:0, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:64, from summat.cpp:1: /usr/include/c++/4.8/bits/stl_algo.h:4236:5: note: template<class _Tp, class _Compare> _Tp std::max(std::initializer_list<_Tp>, _Compare) max(initializer_list<_Tp> __l, _Compare __comp) ^ /usr/include/c++/4.8/bits/stl_algo.h:4236:5: note: template argument deduction/substitution failed: summat.cpp:130:56: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' T += 1LL * v * (c2-max(c1,y1[v])+1); ^ summat.cpp:140:55: warning: pointer to a function used in arithmetic [-Wpointer-arith] T += 1LL * v * (c2-max(c1,y1[v])+1); ^ summat.cpp:140:56: error: no matching function for call to 'max(long long int&, double (&)(double)throw ())' T += 1LL * v * (c2-max(c1,y1[v])+1); ^ summat.cpp:140:56: note: candidates are: 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/sstream:38, from /usr/include/c++/4.8/complex:45, from /usr/include/c++/4.8/ccomplex:38, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:52, from summat.cpp:1: /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) ^ /usr/include/c++/4.8/bits/stl_algobase.h:216:5: note: template argument deduction/substitution failed: summat.cpp:140:56: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'double(double)throw ()') T += 1LL * v * (c2-max(c1,y1[v])+1); ^ 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/sstream:38, from /usr/include/c++/4.8/complex:45, from /usr/include/c++/4.8/ccomplex:38, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:52, from summat.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:260:5: note: template argument deduction/substitution failed: summat.cpp:140:56: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'double(double)throw ()') T += 1LL * v * (c2-max(c1,y1[v])+1); ^ In file included from /usr/include/c++/4.8/algorithm:62:0, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:64, from summat.cpp:1: /usr/include/c++/4.8/bits/stl_algo.h:4231:5: note: template<class _Tp> _Tp std::max(std::initializer_list<_Tp>) max(initializer_list<_Tp> __l) ^ /usr/include/c++/4.8/bits/stl_algo.h:4231:5: note: template argument deduction/substitution failed: summat.cpp:140:56: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' T += 1LL * v * (c2-max(c1,y1[v])+1); ^ In file included from /usr/include/c++/4.8/algorithm:62:0, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:64, from summat.cpp:1: /usr/include/c++/4.8/bits/stl_algo.h:4236:5: note: template<class _Tp, class _Compare> _Tp std::max(std::initializer_list<_Tp>, _Compare) max(initializer_list<_Tp> __l, _Compare __comp) ^ /usr/include/c++/4.8/bits/stl_algo.h:4236:5: note: template argument deduction/substitution failed: summat.cpp:140:56: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' T += 1LL * v * (c2-max(c1,y1[v])+1); ^ summat.cpp:11:22: warning: unused variable 'j' [-Wunused-variable] long long int i, j, k, q, x, v; ^ summat.cpp:11:25: warning: unused variable 'k' [-Wunused-variable] long long int i, j, k, q, x, v; ^ summat.cpp:11:31: warning: unused variable 'x' [-Wunused-variable] long long int i, j, k, q, x, v; ^ summat.cpp:15:22: warning: unused variable 'y3' [-Wunused-variable] long long int x3,y3,x4,y4,nrL, ux, uy, nx, ny; ^ summat.cpp:15:28: warning: unused variable 'y4' [-Wunused-variable] long long int x3,y3,x4,y4,nrL, ux, uy, nx, ny; ^ summat.cpp:15:31: warning: unused variable 'nrL' [-Wunused-variable] long long int x3,y3,x4,y4,nrL, ux, uy, nx, ny; ^ summat.cpp:15:40: warning: unused variable 'uy' [-Wunused-variable] long long int x3,y3,x4,y4,nrL, ux, uy, nx, ny; ^ summat.cpp:15:44: warning: unused variable 'nx' [-Wunused-variable] long long int x3,y3,x4,y4,nrL, ux, uy, nx, ny; ^ summat.cpp:15:48: warning: unused variable 'ny' [-Wunused-variable] long long int x3,y3,x4,y4,nrL, ux, uy, nx, ny; ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema summat 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ă.