#1991
Trepte2
O persoana are de urcat n
trepte. Ştiind că de pe treapta i
poate trece pe treapta i + 1, i + 2, ..., i + (k - 1)
sau i + k
, aflaţi în câte moduri poate urca cele n
trepte. (inițial este pe treapta 1
)
Problema | Trepte2 | Operații I/O | tastatură/ecran |
---|---|---|---|
Limita timp | 1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
Id soluție | #19412076 | Utilizator | |
Fișier | trepte2.cpp | Dimensiune | 677 B |
Data încărcării | 07 Decembrie 2019, 13:28 | Scor / rezultat | Eroare de compilare |
trepte2.cpp:2:1: error: stray '\302' in program using namespace std;int v[100002], n , k, nr;int solutie(int x){ return (v[x] == n);}int valid(int x){ if (x > 1) { for (int i = 1; i < x; i++) if (v[x] == v[i]) return 0; if (v[x - 1] > v[x]) return 0; if (v[x] - v[x- 1] > k) return 0; } return 1;}void Back(int x){ for (int i = 1; i <= n; i++) { v[x] = i; if (valid(x)) if (solutie(x)) nr++; else Back(x + 1); }}int main(){ cin >> n >> k; v[1] = 1; Back(2); cout << nr; return 0;} ^ trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp:2:1: error: stray '\302' in program trepte2.cpp:2:1: error: stray '\240' in program trepte2.cpp: In function 'void Back(int)': trepte2.cpp:2:457: warning: suggest explicit braces to avoid ambiguous 'else' [-Wparentheses] using namespace std;int v[100002], n , k, nr;int solutie(int x){ return (v[x] == n);}int valid(int x){ if (x > 1) { for (int i = 1; i < x; i++) if (v[x] == v[i]) return 0; if (v[x - 1] > v[x]) return 0; if (v[x] - v[x- 1] > k) return 0; } return 1;}void Back(int x){ for (int i = 1; i <= n; i++) { v[x] = i; if (valid(x)) if (solutie(x)) nr++; else Back(x + 1); }}int main(){ cin >> n >> k; v[1] = 1; Back(2); cout << nr; return 0;} ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema Trepte2 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ă.