#3433
Forta
Forța unui număr natural nenul X
este egală cu numărul de divizori pozitivi ai lui X
. De exemplu, numărul X = 10
are forţa 4
, deoarece 10
are 4
divizori, mulțimea divizorilor fiind D
10
= {1,2,5,10}
.
Scrieţi un program care, cunoscând un șir de n
numere naturale nenule, rezolvă următoarele cerințe:
1. determină cel mai mic număr din șir care are forța maximă;
2. determină lungimea maximă a unei secvențe formată din numere cu aceeași forţă ce poate fi obținută prin rearanjarea convenabilă a elementelor din șir.
OJI 2020, clasa a VI-a
Problema | Forta | Operații I/O |
forta.in /forta.out
|
---|---|---|---|
Limita timp | 0.5 secunde | Limita memorie |
Total: 16 MB
/
Stivă 8 MB
|
Id soluție | #49814426 | Utilizator | |
Fișier | forta.cpp | Dimensiune | 1.98 KB |
Data încărcării | 15 Martie 2024, 16:49 | Scor / rezultat | Eroare de compilare |
forta.cpp:9:1: error: stray '\310' in program int calculForță(int număr) { ^ forta.cpp:9:1: error: stray '\233' in program forta.cpp:9:1: error: stray '\304' in program forta.cpp:9:1: error: stray '\203' in program forta.cpp:9:1: error: stray '\304' in program forta.cpp:9:1: error: stray '\203' in program forta.cpp:10:5: error: stray '\310' in program int forță = 0; ^ forta.cpp:10:5: error: stray '\233' in program forta.cpp:10:5: error: stray '\304' in program forta.cpp:10:5: error: stray '\203' in program forta.cpp:11:5: error: stray '\304' in program for (int i = 1; i * i <= număr; ++i) { ^ forta.cpp:11:5: error: stray '\203' in program forta.cpp:12:9: error: stray '\304' in program if (număr % i == 0) { ^ forta.cpp:12:9: error: stray '\203' in program forta.cpp:14:13: error: stray '\304' in program if (i * i == număr) { ^ forta.cpp:14:13: error: stray '\203' in program forta.cpp:15:17: error: stray '\310' in program forță++; ^ forta.cpp:15:17: error: stray '\233' in program forta.cpp:15:17: error: stray '\304' in program forta.cpp:15:17: error: stray '\203' in program forta.cpp:17:17: error: stray '\310' in program forță += 2; ^ forta.cpp:17:17: error: stray '\233' in program forta.cpp:17:17: error: stray '\304' in program forta.cpp:17:17: error: stray '\203' in program forta.cpp:21:5: error: stray '\310' in program return forță; ^ forta.cpp:21:5: error: stray '\233' in program forta.cpp:21:5: error: stray '\304' in program forta.cpp:21:5: error: stray '\203' in program forta.cpp:28:5: error: stray '\310' in program int cerință; ^ forta.cpp:28:5: error: stray '\233' in program forta.cpp:28:5: error: stray '\304' in program forta.cpp:28:5: error: stray '\203' in program forta.cpp:29:5: error: stray '\310' in program cin >> cerință; ^ forta.cpp:29:5: error: stray '\233' in program forta.cpp:29:5: error: stray '\304' in program forta.cpp:29:5: error: stray '\203' in program forta.cpp:35:5: error: stray '\310' in program unordered_map<int, int> forțe; // pentru a memora numărul de apariții ale fiecărei forțe ^ forta.cpp:35:5: error: stray '\233' in program forta.cpp:39:9: error: stray '\310' in program forțe[calculForță(numere[i])]++; // calculăm forța fiecărui număr și memorăm numărul de apariții ^ forta.cpp:39:9: error: stray '\233' in program forta.cpp:39:9: error: stray '\310' in program forta.cpp:39:9: error: stray '\233' in program forta.cpp:39:9: error: stray '\304' in program forta.cpp:39:9: error: stray '\203' in program forta.cpp:42:5: error: stray '\310' in program if (cerință == 1) { ^ forta.cpp:42:5: error: stray '\233' in program forta.cpp:42:5: error: stray '\304' in program forta.cpp:42:5: error: stray '\203' in program forta.cpp:44:9: error: stray '\310' in program int maximForță = 0; ^ forta.cpp:44:9: error: stray '\233' in program forta.cpp:44:9: error: stray '\304' in program forta.cpp:44:9: error: stray '\203' in program forta.cpp:45:9: error: stray '\310' in program for (auto it : forțe) { ^ forta.cpp:45:9: error: stray '\233' in program forta.cpp:46:13: error: stray '\310' in program maximForță = max(maximForță, it.first); ^ forta.cpp:46:13: error: stray '\233' in program forta.cpp:46:13: error: stray '\304' in program forta.cpp:46:13: error: stray '\203' in program forta.cpp:46:13: error: stray '\310' in program forta.cpp:46:13: error: stray '\233' in program forta.cpp:46:13: error: stray '\304' in program forta.cpp:46:13: error: stray '\203' in program forta.cpp:50:9: error: stray '\304' in program int minimNumărForțăMaximă = numeric_limits<int>::max(); ^ forta.cpp:50:9: error: stray '\203' in program forta.cpp:50:9: error: stray '\310' in program forta.cpp:50:9: error: stray '\233' in program forta.cpp:50:9: error: stray '\304' in program forta.cpp:50:9: error: stray '\203' in program forta.cpp:50:9: error: stray '\304' in program forta.cpp:50:9: error: stray '\203' in program forta.cpp:52:13: error: stray '\310' in program if (calculForță(numere[i]) == maximForță) { ^ forta.cpp:52:13: error: stray '\233' in program forta.cpp:52:13: error: stray '\304' in program forta.cpp:52:13: error: stray '\203' in program forta.cpp:52:13: error: stray '\310' in program forta.cpp:52:13: error: stray '\233' in program forta.cpp:52:13: error: stray '\304' in program forta.cpp:52:13: error: stray '\203' in program forta.cpp:53:17: error: stray '\304' in program minimNumărForțăMaximă = min(minimNumărForțăMaximă, numere[i]); ^ forta.cpp:53:17: error: stray '\203' in program forta.cpp:53:17: error: stray '\310' in program forta.cpp:53:17: error: stray '\233' in program forta.cpp:53:17: error: stray '\304' in program forta.cpp:53:17: error: stray '\203' in program forta.cpp:53:17: error: stray '\304' in program forta.cpp:53:17: error: stray '\203' in program forta.cpp:53:17: error: stray '\304' in program forta.cpp:53:17: error: stray '\203' in program forta.cpp:53:17: error: stray '\310' in program forta.cpp:53:17: error: stray '\233' in program forta.cpp:53:17: error: stray '\304' in program forta.cpp:53:17: error: stray '\203' in program forta.cpp:53:17: error: stray '\304' in program forta.cpp:53:17: error: stray '\203' in program forta.cpp:56:9: error: stray '\304' in program cout << minimNumărForțăMaximă << endl; ^ forta.cpp:56:9: error: stray '\203' in program forta.cpp:56:9: error: stray '\310' in program forta.cpp:56:9: error: stray '\233' in program forta.cpp:56:9: error: stray '\304' in program forta.cpp:56:9: error: stray '\203' in program forta.cpp:56:9: error: stray '\304' in program forta.cpp:56:9: error: stray '\203' in program forta.cpp:57:5: error: stray '\310' in program } else if (cerință == 2) { ^ forta.cpp:57:5: error: stray '\233' in program forta.cpp:57:5: error: stray '\304' in program forta.cpp:57:5: error: stray '\203' in program forta.cpp:59:9: error: stray '\304' in program int lungimeMaximă = 0; ^ forta.cpp:59:9: error: stray '\203' in program forta.cpp:60:9: error: stray '\310' in program for (auto it : forțe) { ^ forta.cpp:60:9: error: stray '\233' in program forta.cpp:61:13: error: stray '\304' in program lungimeMaximă = max(lungimeMaximă, it.second); ^ forta.cpp:61:13: error: stray '\203' in program forta.cpp:61:13: error: stray '\304' in program forta.cpp:61:13: error: stray '\203' in program forta.cpp:63:9: error: stray '\304' in program cout << lungimeMaximă << endl; ^ forta.cpp:63:9: error: stray '\203' in program forta.cpp:9:28: error: expected ',' or '...' before 'r' int calculForță(int număr) { ^ forta.cpp: In function 'int calculFor(int)': forta.cpp:10:9: error: expected unqualified-id before 'for' int forță = 0; ^ forta.cpp:11:35: error: expected ';' before 'r' for (int i = 1; i * i <= număr; ++i) { ^ forta.cpp:11:35: error: 'r' was not declared in this scope forta.cpp:11:36: error: expected ')' before ';' token for (int i = 1; i * i <= număr; ++i) { ^ forta.cpp:11:40: error: 'i' was not declared in this scope for (int i = 1; i * i <= număr; ++i) { ^ forta.cpp:11:41: error: expected ';' before ')' token for (int i = 1; i * i <= număr; ++i) { ^ forta.cpp:67:1: error: expected '}' at end of input } ^ forta.cpp:67:1: warning: no return statement in function returning non-void [-Wreturn-type]
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema Forta 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ă.