|
|
back to boardFilippov Nickolas SSAU#2's AC program is HERE! program luckytickets; var a:array[0..36] of longint; i,j,k:integer; n:integer; chislo:longint; begin readln(n); fillchar(a,sizeof(a),0); if n mod 2 = 1 then writeln(1) else begin for i:=0 to 9 do a[i]:=1; for i:=2 to (n div 2) do for k:=i*9 downto 0 do begin chislo:=0; for j:=0 to 9 do if (k-j)>=0 then chislo:=chislo+a[k-j]; a[k]:=chislo; end; chislo:=0; for i:=0 to (n div 2)*9 do chislo:=chislo+a[i]*a[i]; writeln(chislo); end; end. Re: Filippov Nickolas SSAU#2's AC program is HERE! > program luckytickets; > var a:array[0..36] of longint; > i,j,k:integer; > n:integer; > chislo:longint; > begin > readln(n); > fillchar(a,sizeof(a),0); > if n mod 2 = 1 then writeln(1) else > begin > for i:=0 to 9 do a[i]:=1; > for i:=2 to (n div 2) do > for k:=i*9 downto 0 do begin > chislo:=0; > for j:=0 to 9 do > if (k-j)>=0 then chislo:=chislo+a[k-j]; > a[k]:=chislo; > end; > chislo:=0; > for i:=0 to (n div 2)*9 do chislo:=chislo+a[i]*a[i]; > writeln(chislo); > end; > end. > Is this solution Dynamic Programming? |
|
|