#1322
PartitiiNr
Se dă un număr natural n
. Determinaţi, în ordine lexicografică, toate modalităţile de a-l scrie pe n
ca sumă de numere naturale ordonate crescător astfel încât diferența dintre doi termeni consecutivi ai sumei să fie cel puțin 2
.
Problema | PartitiiNr | Operații I/O |
partitiinr.in /partitiinr.out
|
---|---|---|---|
Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
Id soluție | #54007590 | Utilizator | |
Fișier | partitiinr.cpp | Dimensiune | 770 B |
Data încărcării | 17 Noiembrie 2024, 18:25 | Scor / rezultat | Eroare de compilare |
partitiinr.cpp:6:1: error: expected ',' or ';' before 'ofstream' ofstream out ("partitiinr.out") ^ partitiinr.cpp: In function 'void afis(int)': partitiinr.cpp:11:4: error: 'out' was not declared in this scope out<<sol[i]<<" "; ^ partitiinr.cpp:11:9: error: 'sol' was not declared in this scope out<<sol[i]<<" "; ^ partitiinr.cpp:12:3: error: 'out' was not declared in this scope out<<"\n"; ^ partitiinr.cpp:13:3: error: 's' was not declared in this scope s=s-sol[k]; ^ partitiinr.cpp:13:7: error: 'sol' was not declared in this scope s=s-sol[k]; ^ partitiinr.cpp: In function 'int valid(int)': partitiinr.cpp:18:8: error: 'sol' was not declared in this scope if(sol[k]==sol[i]) return 0; ^ partitiinr.cpp:19:16: error: 'sol' was not declared in this scope if(k>1 and sol[k]<sol[k-1]) return 0; ^ partitiinr.cpp:20:17: error: 'sol' was not declared in this scope if(k>1 and (sol[k]-sol[k-1])<2) return 0; ^ partitiinr.cpp:21:6: error: 's' was not declared in this scope if(s+sol[k]<=n){ ^ partitiinr.cpp:21:8: error: 'sol' was not declared in this scope if(s+sol[k]<=n){ ^ partitiinr.cpp:21:16: error: 'n' was not declared in this scope if(s+sol[k]<=n){ ^ partitiinr.cpp: In function 'int solut(int)': partitiinr.cpp:30:5: error: 's' was not declared in this scope if(s==n) return 1; ^ partitiinr.cpp:30:8: error: 'n' was not declared in this scope if(s==n) return 1; ^ partitiinr.cpp: In function 'int bkt(int)': partitiinr.cpp:35:16: error: 'n' was not declared in this scope for(int i=1;i<=n;i++){ ^ partitiinr.cpp:36:9: error: 'sol' was not declared in this scope sol[k]=i; ^ partitiinr.cpp:37:7: warning: suggest explicit braces to avoid ambiguous 'else' [-Wparentheses] if(valid(k)) ^ partitiinr.cpp:42:3: error: 's' was not declared in this scope s=s-sol[k-1]; ^ partitiinr.cpp:42:7: error: 'sol' was not declared in this scope s=s-sol[k-1]; ^ partitiinr.cpp:43:1: warning: no return statement in function returning non-void [-Wreturn-type] } ^ partitiinr.cpp: In function 'int main()': partitiinr.cpp:46:9: error: 'n' was not declared in this scope in>>n; ^ partitiinr.cpp: In function 'int valid(int)': partitiinr.cpp:27:1: warning: control reaches end of non-void function [-Wreturn-type] } ^ partitiinr.cpp: In function 'int solut(int)': partitiinr.cpp:32:1: warning: control reaches end of non-void function [-Wreturn-type] } ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema PartitiiNr 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ă.