|
|
back to boardWhat's test#1 ???? and my wrong pascal solution I am failing test#1 var minked,j,i,k,n : byte; tsum,sum: longint; BEGIN readln(n); readln(k); sum:=0; if (n mod 2=0) then minked:=(n div 2) else minked:=(n div 2)+1; for i:=minked to n do begin tsum:=1; for j:=1 to i do begin tsum:=tsum*(k-1); end; sum:=sum+tsum; end; writeln(sum); END. Re: What's test#1 ???? and my wrong pascal solution Posted by МОП 14 Aug 2013 13:10 Lual.ru Re: What's test#1 ???? and my wrong pascal solution Posted by vcvycy 3 Oct 2013 19:45 var i,j,k,m,n,ans:Longint; procedure search(m,p,plus:Longint); begin if m=n+1 then begin ans:=ans+plus;exit;end; if p<>0 then search(m+1,0,plus); search(m+1,1,plus*(k-1)); end; begin read(n,k); search(1,0,1); writeln(ans); end. dfs纯暴力.. |
|
|