Cele mai bune solutii
pentru problema "Numar Curios"
(ziua1, problema2)
Punctaj Maxim : 30 puncte
Solutii :
Sabau Florin - Caras Severin
Marina Constantin - Alba - 30 puncte;
Nechita Onu - Olt - 30 puncte;
Patrascu Mihai - Dolj - 30 puncte;
Balan Horia - Bihor - 30 puncte;
Trifan Ionut - Buzau - 30 puncte;
Stan Bogdan - Prahova - 30 puncte;
Pandia Ilie - Valcea - 30 puncte;
Badita Robert - Dolj - 30 puncte;
Adler Andrei - Bucuresti - 30 puncte;
Doncea Madalin - Arges - 30 puncte;
Fisierele de teste
Program realizat de elevul Sabau Florin - rezultat final : premiu II - 110 puncte
uses crt; var f: text; n,i,x,k,swap: integer; a,b: array[1..10000] of byte; gata: boolean; function cauta(nr,swap: integer): integer ; var x,j: integer; begin x:=0; for j:=0 to 9 do if (j*3+swap) mod 10=nr then begin x:=j; break; end; cauta:=x; end; procedure solutie; var j: integer; begin assign(f,'output.txt'); rewrite(f); for j:=1 to i do write(f,a[j]); close(f); gata:=true; end; begin clrscr; assign(f,'input.txt'); reset(f); readln(f,n); i:=n; if i=1 then i:=2; repeat for k:=1 to n do begin a[k]:=0; b[k]:=0; end; a[1]:=1; b[i]:=1; a[i]:=7; b[i-1]:=a[i]; swap:=2; gata:=false; for k:=i-1 downto 2 do begin x:=cauta(b[k],swap); a[k]:=x; b[k-1]:=x; swap:=(x*3) div 10; end; if b[1]=3+swap then solutie; i:=i+1; until gata ; { if (i>40) and not(gata) then begin assign(f,'output.txt'); rewrite(f); close(f); end;{} end.
Test 1 :
3
Test 2 :
6
Test 3 :
13
Test 4 :
20
Test 5 :
30
Test 6 :
40