#740
Horse
Se consideră o tablă de şah cu n
linii şi n
coloane, şi n=4k+1
. Liniile acestei table sunt numerotate de sus în jos începând cu linia 1
, iar coloanele sunt numerotate de la stânga la dreapta începând cu 1
. În fiecare dintre câmpurile acestei table se scrie câte un număr natural din mulţimea {1, 2, …, n
2
}
după următoarele reguli:
a) se porneşte din colţul aflat în poziţia stânga sus al tablei şi se avansează utilizând săritura calului
b) se merge orizontal către dreapta şi în continuare, pe chenarul format din primele două linii, primele două coloane, ultimele două linii şi ultimele două coloane, în sensul acelor de ceasornic;
c) se efectuează mai multe tururi ale tablei, până ce se umple întregul chenar, fără să se sară de două ori în aceeaşi căsuţă, fără să se sară în afara acestui chenar şi fără să rămână vreun câmp liber;
d) din poziţia finală în care s-a ajuns, trebuie să fie posibilă săritura în colţul din stânga sus al pătratului rămas neacoperit;
e) se continuă deplasarea în interiorul pătratului rămas neacoperit, folosind regulile a), b), c), d) până ce se ajunge la pătratul interior de latură 1 care va conţine valoarea n
2
.
Cunoscând valoarea lui n
ce reprezintă dimensiunea tablei şi un număr p
, să se determine linia şi coloana căsuţei din tabelă unde este scris numărul p
, după regulile de mai sus.
Problema | Horse | Operații I/O |
horse.in /horse.out
|
---|---|---|---|
Limita timp | 0.25 secunde | Limita memorie |
Total: 2 MB
/
Stivă 2 MB
|
Id soluție | #52407272 | Utilizator | |
Fișier | horse.cpp | Dimensiune | 2.54 KB |
Data încărcării | 29 Septembrie 2024, 14:53 | Scor / rezultat | Eroare de compilare |
horse.cpp:2:11: warning: character constant too long for its type [enabled by default] const fin='horse.in'; ^ horse.cpp:3:12: warning: character constant too long for its type [enabled by default] fout='horse.out'; ^ horse.cpp:1:1: error: 'program' does not name a type program horses; ^ horse.cpp:2:7: error: 'fin' does not name a type const fin='horse.in'; ^ horse.cpp:3:7: error: 'fout' does not name a type fout='horse.out'; ^ horse.cpp:4:1: error: 'var' does not name a type var l,c,rest,n,p,i,j:longint; ^ horse.cpp:5:5: error: 'f' does not name a type f,g:text; ^ horse.cpp:6:1: error: 'procedure' does not name a type procedure horse(n,p:longint;var l,c:longint); ^ horse.cpp:6:29: error: 'var' does not name a type procedure horse(n,p:longint;var l,c:longint); ^ horse.cpp:7:1: error: 'var' does not name a type var q:longint; ^ horse.cpp:8:1: error: 'begin' does not name a type begin ^ horse.cpp:12:7: error: 'c' does not name a type c:=l; ^ horse.cpp:13:7: error: 'exit' does not name a type exit; ^ horse.cpp:14:5: error: 'end' does not name a type end; ^ horse.cpp:15:3: error: 'rest' does not name a type rest:=0; ^ horse.cpp:16:3: error: expected unqualified-id before 'while' while (p>8*n-16) do ^ horse.cpp:19:7: error: 'p' does not name a type p:=p-8*n+16; ^ horse.cpp:20:7: error: 'n' does not name a type n:=n-4; ^ horse.cpp:21:5: error: 'end' does not name a type end; ^ horse.cpp:22:3: error: expected unqualified-id before 'if' if (p<=n div 2) then ^ horse.cpp:25:7: error: 'c' does not name a type c:=2*q-1+rest; ^ horse.cpp:26:7: error: 'l' does not name a type l:=2-q mod 2+rest; ^ horse.cpp:27:5: error: 'end' does not name a type end; ^ horse.cpp:28:3: error: expected unqualified-id before 'if' if (p>n div 2) and (p<n) then ^ horse.cpp:31:7: error: 'c' does not name a type c:=n-1+q mod 2 + rest; ^ horse.cpp:32:7: error: 'l' does not name a type l:=2*q-1+rest; ^ horse.cpp:33:5: error: 'end' does not name a type end; ^ horse.cpp:34:3: error: expected unqualified-id before 'if' if (p>=n) and (p<n + n div 2) then ^ horse.cpp:37:7: error: 'c' does not name a type c:=n-2*q+rest; ^ horse.cpp:38:7: error: 'l' does not name a type l:=n-q mod 2+rest; ^ horse.cpp:39:5: error: 'end' does not name a type end; ^ horse.cpp:40:3: error: expected unqualified-id before 'if' if (p>=n+n div 2) and (p<2*n-1) then ^ horse.cpp:43:7: error: 'l' does not name a type l:=n-2*q+rest; ^ horse.cpp:44:7: error: 'c' does not name a type c:=1+q mod 2+rest; ^ horse.cpp:45:5: error: 'end' does not name a type end; ^ horse.cpp:46:3: error: expected unqualified-id before 'if' if (p>=2*n-1) and (p<2*n-2+ n div 2) then ^ horse.cpp:49:7: error: 'c' does not name a type c:=2*q+3+rest; ^ horse.cpp:50:7: error: 'l' does not name a type l:=1+q mod 2+rest; ^ horse.cpp:51:5: error: 'end' does not name a type end; ^ horse.cpp:52:3: error: expected unqualified-id before 'if' if (p>=2*n-2+ n div 2) and (p<3*n-3) then ^ horse.cpp:55:7: error: 'c' does not name a type c:=n-q mod 2 + rest; ^ horse.cpp:56:7: error: 'l' does not name a type l:=2*q+2+rest; ^ horse.cpp:57:5: error: 'end' does not name a type end; ^ horse.cpp:58:3: error: expected unqualified-id before 'if' if (p>=3*n-3) and (p<3*n-4+n div 2) then ^ horse.cpp:61:7: error: 'c' does not name a type c:=n-2*q-3+rest; ^ horse.cpp:62:7: error: 'l' does not name a type l:=n-q mod 2+rest; ^ horse.cpp:63:5: error: 'end' does not name a type end; ^ horse.cpp:64:3: error: expected unqualified-id before 'if' if (p>=3*n-4+n div 2) and (p<4*n-6) then ^ horse.cpp:67:7: error: 'l' does not name a type l:=n-2*q-2+rest; ^ horse.cpp:68:7: error: 'c' does not name a type c:=1+q mod 2+rest; ^ horse.cpp:69:5: error: 'end' does not name a type end; ^ horse.cpp:70:3: error: expected unqualified-id before 'if' if (p>=4*n-6) and (p<4*n-6+ n div 2) then ^ horse.cpp:73:7: error: 'c' does not name a type c:=2*q+2+rest; ^ horse.cpp:74:7: error: 'l' does not name a type l:=1+q mod 2+rest; ^ horse.cpp:75:5: error: 'end' does not name a type end; ^ horse.cpp:76:3: error: expected unqualified-id before 'if' if (p>=4*n-6+ n div 2) and (p<5*n-8) then ^ horse.cpp:79:7: error: 'c' does not name a type c:=n-q mod 2 + rest; ^ horse.cpp:80:7: error: 'l' does not name a type l:=2*q+4+rest; ^ horse.cpp:81:5: error: 'end' does not name a type end; ^ horse.cpp:82:3: error: expected unqualified-id before 'if' if (p>=5*n-8) and (p<5*n-9+n div 2) then ^ horse.cpp:85:7: error: 'c' does not name a type c:=n-2*q-2+rest; ^ horse.cpp:86:7: error: 'l' does not name a type l:=n-q mod 2+rest; ^ horse.cpp:87:5: error: 'end' does not name a type end; ^ horse.cpp:88:3: error: expected unqualified-id before 'if' if (p>=5*n-9+n div 2) and (p<6*n-11) then ^ horse.cpp:91:7: error: 'l' does not name a type l:=n-2*q-1+rest; ^ horse.cpp:92:7: error: 'c' does not name a type c:=1+q mod 2+rest; ^ horse.cpp:93:5: error: 'end' does not name a type end; ^ horse.cpp:94:3: error: expected unqualified-id before 'if' if (p>=6*n-11) and (p<6*n-11+ n div 2) then ^ horse.cpp:97:7: error: 'c' does not name a type c:=2*q+2+rest; ^ horse.cpp:98:7: error: 'l' does not name a type l:=2-q mod 2+rest; ^ horse.cpp:99:5: error: 'end' does not name a type end; ^ horse.cpp:100:3: error: expected unqualified-id before 'if' if (p>=6*n-11+ n div 2) and (p<7*n-13) then ^ horse.cpp:103:7: error: 'c' does not name a type c:=n-q mod 2 + rest; ^ horse.cpp:104:7: error: 'l' does not name a type l:=2*q+3+rest; ^ horse.cpp:105:5: error: 'end' does not name a type end; ^ horse.cpp:106:3: error: expected unqualified-id before 'if' if (p>=7*n-13) and (p<7*n-13+n div 2) then ^ horse.cpp:109:7: error: 'c' does not name a type c:=n-2*q-1+rest; ^ horse.cpp:110:7: error: 'l' does not name a type l:=n-q mod 2+rest; ^ horse.cpp:111:5: error: 'end' does not name a type end; ^ horse.cpp:112:3: error: expected unqualified-id before 'if' if (p>=7*n-13+n div 2) and (p<8*n-15) then ^ horse.cpp:115:7: error: 'l' does not name a type l:=n-2*q-3+rest; ^ horse.cpp:116:7: error: 'c' does not name a type c:=1+q mod 2+rest; ^ horse.cpp:117:5: error: 'end' does not name a type end; ^ horse.cpp:118:1: error: 'end' does not name a type end; ^ horse.cpp:119:1: error: 'begin' does not name a type begin ^ horse.cpp:121:8: error: expected constructor, destructor, or type conversion before '(' token reset(f); ^ horse.cpp:122:9: error: expected constructor, destructor, or type conversion before '(' token readln(f,n); ^ horse.cpp:123:9: error: expected constructor, destructor, or type conversion before '(' token readln(f,p); ^ horse.cpp:124:8: error: expected constructor, destructor, or type conversion before '(' token close(f); ^ horse.cpp:125:9: error: expected constructor, destructor, or type conversion before '(' token assign(g,fout); ^ horse.cpp:126:10: error: expected constructor, destructor, or type conversion before '(' token rewrite(g); ^ horse.cpp:127:3: error: 'l' does not name a type l:=0;c:=0; ^ horse.cpp:127:8: error: 'c' does not name a type l:=0;c:=0; ^ horse.cpp:128:8: error: expected constructor, destructor, or type conversion before '(' token horse(n,p,l,c); ^ horse.cpp:129:10: error: expected constructor, destructor, or type conversion before '(' token writeln(g,l,' ',c); ^ horse.cpp:130:8: error: expected constructor, destructor, or type conversion before '(' token close(g); ^ horse.cpp:131:1: error: 'end' does not name a type end. ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema Horse 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ă.