#2812
Se dă un șir de cel mult 106 numere naturale din intervalul [0,103]. Se cere să se verifice dacă există un număr natural r, astfel încât toate numerele distincte din șir să poată fi rearanjate, pentru a forma o progresie aritmetică de rație r. Se afișează numărul r, sau mesajul NU, dacă nu există un astfel de număr.
Subiect Bacalaureat 2017, sesiune august-septembrie
| Problema | Progresie3 | Operații I/O |
progresie3.in/progresie3.out
|
|---|---|---|---|
| Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
| Id soluție | #64800861 | Utilizator | |
| Fișier | progresie3.cpp | Dimensiune | 336 B |
| Data încărcării | 02 Iunie 2026, 10:51 | Scor/rezultat | Eroare de compilare |
progresie3.cpp:2:1: error: ‘ifstream’ does not name a type 2 | ifstream f("progresie3.in"); | ^~~~~~~~ progresie3.cpp:3:1: error: ‘ofstream’ does not name a type 3 | ofstream g("progresie3.out"); | ^~~~~~~~ progresie3.cpp:5:23: error: expected unqualified-id before ‘bool’ 5 | int v[1000], i, r, x, bool ok=1;; | ^~~~ progresie3.cpp: In function ‘int main()’: progresie3.cpp:7:9: error: ‘f’ was not declared in this scope 7 | {while (f>>x) v[x]++; | ^ progresie3.cpp:8:2: warning: this ‘for’ clause does not guard... [-Wmisleading-indentation] 8 | for(i=0;i<1007&&v[i]==0;i++) | ^~~ progresie3.cpp:9:11: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘for’ 9 | x=1; i++; | ^ progresie3.cpp:12:21: error: ‘g’ was not declared in this scope 12 | if(i-x!=r){g<<"NU";i=1007; ok=0;} | ^ progresie3.cpp:12:37: error: ‘ok’ was not declared in this scope 12 | if(i-x!=r){g<<"NU";i=1007; ok=0;} | ^~ progresie3.cpp:14:2: error: ‘sort’ was not declared in this scope; did you mean ‘short’? 14 | sort | ^~~~ | short progresie3.cpp:14:6: error: expected ‘}’ at end of input 14 | sort | ^ progresie3.cpp:13:15: note: to match this ‘{’ 13 | else { | ^ progresie3.cpp:14:6: error: expected ‘}’ at end of input 14 | sort | ^ progresie3.cpp:11:9: note: to match this ‘{’ 11 | {while(v[i]==0) i++; | ^ progresie3.cpp:14:6: error: expected ‘}’ at end of input 14 | sort | ^ progresie3.cpp:7:1: note: to match this ‘{’ 7 | {while (f>>x) v[x]++; | ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema Progresie3 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ă.