#3822
Se dă un vector A de N elemente. Trebuie să calculați suma celui mai mare divizor comun din toate secvențele vectorului . Mai formal , notând cu F(st , dr) = cmmdc(A[st] , A[st+1] ... A[dr]) 1 <= st <= dr <= N , trebuie să calculați suma tuturor F(st , dr) posibile.
infoleague.net etapa 1, problema 2.
| Problema | GCD2 | Operații I/O |
gcd2.in/gcd2.out
|
|---|---|---|---|
| Limita timp | 0.2 secunde | Limita memorie |
Total: 64 MB
/
Stivă 32 MB
|
| Id soluție | #60169561 | Utilizator | |
| Fișier | gcd2.cpp | Dimensiune | 1.08 KB |
| Data încărcării | 20 Octombrie 2025, 15:14 | Scor/rezultat | Eroare de compilare |
gcd2.cpp:6:22: warning: missing terminating ' character [enabled by default] const int MAX_N = 100'000; ^ gcd2.cpp:6:1: error: missing terminating ' character const int MAX_N = 100'000; ^ gcd2.cpp:8:1: error: expected ',' or ';' before 'struct' struct Baiatu { ^ gcd2.cpp: In function 'int main()': gcd2.cpp:27:15: error: 'Baiatu' was not declared in this scope std::vector<Baiatu> v; ^ gcd2.cpp:27:21: error: template argument 1 is invalid std::vector<Baiatu> v; ^ gcd2.cpp:27:21: error: template argument 2 is invalid gcd2.cpp:27:24: error: invalid type in declaration before ';' token std::vector<Baiatu> v; ^ gcd2.cpp:29:19: error: found ':' in nested-name-specifier, expected '::' for(Baiatu& x : v) { ^ gcd2.cpp:29:17: error: 'x' has not been declared for(Baiatu& x : v) { ^ gcd2.cpp:29:22: error: expected ';' before ')' token for(Baiatu& x : v) { ^ gcd2.cpp:33:7: error: request for member 'push_back' in 'v', which is of non-class type 'int' v.push_back({a[i], 1}); ^ gcd2.cpp:34:17: error: request for member 'begin' in 'v', which is of non-class type 'int' std::sort(v.begin(), v.end(), [](const Baiatu& a, const Baiatu& b) { ^ gcd2.cpp:34:28: error: request for member 'end' in 'v', which is of non-class type 'int' std::sort(v.begin(), v.end(), [](const Baiatu& a, const Baiatu& b) { ^ gcd2.cpp:34:44: error: 'Baiatu' does not name a type std::sort(v.begin(), v.end(), [](const Baiatu& a, const Baiatu& b) { ^ gcd2.cpp:36:5: error: ISO C++ forbids declaration of 'parameter' with no type [-fpermissive] }); ^ gcd2.cpp: In lambda function: gcd2.cpp:36:7: error: expected '{' before ';' token }); ^ gcd2.cpp: In function 'int main()': gcd2.cpp:36:7: error: expected ')' before ';' token gcd2.cpp:36:7: error: expected ')' before ';' token gcd2.cpp:38:20: error: request for member 'size' in 'v', which is of non-class type 'int' int sz = int(v.size()); ^ gcd2.cpp:39:17: error: the value of 'Baiatu' is not usable in a constant expression std::vector<Baiatu> new_v; ^ gcd2.cpp:27:15: note: 'Baiatu' was not declared 'constexpr' std::vector<Baiatu> v; ^ gcd2.cpp:39:23: error: type/value mismatch at argument 1 in template parameter list for 'template<class _Tp, class _Alloc> class std::vector' std::vector<Baiatu> new_v; ^ gcd2.cpp:39:23: error: expected a type, got 'Baiatu' gcd2.cpp:39:23: error: template argument 2 is invalid gcd2.cpp:39:30: error: invalid type in declaration before ';' token std::vector<Baiatu> new_v; ^ gcd2.cpp:40:11: error: request for member 'push_back' in 'new_v', which is of non-class type 'int' new_v.push_back(v[0]); ^ gcd2.cpp:40:24: error: invalid types 'int[int]' for array subscript new_v.push_back(v[0]); ^ gcd2.cpp:42:13: error: invalid types 'int[int]' for array subscript if(v[i].g != v[i - 1].g) { ^ gcd2.cpp:42:27: error: invalid types 'int[int]' for array subscript if(v[i].g != v[i - 1].g) { ^ gcd2.cpp:43:15: error: request for member 'push_back' in 'new_v', which is of non-class type 'int' new_v.push_back(v[i]); ^ gcd2.cpp:43:28: error: invalid types 'int[int]' for array subscript new_v.push_back(v[i]); ^ gcd2.cpp:45:15: error: request for member 'back' in 'new_v', which is of non-class type 'int' new_v.back().ways += v[i].ways; ^ gcd2.cpp:45:33: error: invalid types 'int[int]' for array subscript new_v.back().ways += v[i].ways; ^ gcd2.cpp:50:15: error: 'Baiatu' does not name a type for(const Baiatu& x : v) { ^ gcd2.cpp:53:3: error: expected ';' before '}' token } ^ gcd2.cpp:53:3: error: expected primary-expression before '}' token gcd2.cpp:53:3: error: expected ';' before '}' token gcd2.cpp:53:3: error: expected primary-expression before '}' token gcd2.cpp:53:3: error: expected ')' before '}' token gcd2.cpp:53:3: error: expected primary-expression before '}' token gcd2.cpp:53:3: error: expected ';' before '}' token gcd2.cpp:20:24: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result] fscanf(fin, "%d", &n); ^ gcd2.cpp:23:29: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result] fscanf(fin, "%d", &a[i]); ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema GCD2 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ă.