|
|
back to boarda program tell me wht doesn't this program work? or at least tell me an example that my program doesn't give us the right answer var l,n,k :integer; sum :longint; function c(a,b:integer):integer; var i,a1,b1,a1b1:integer; begin a1:=1; for i:=1 to a do a1:=a1*i; b1:=1; for i:=1 to b do b1:=b1*i; a1b1:=1; for i:=1 to a-b do a1b1:=a1b1*i; c:=a1 div (b1*a1b1); end; function power(r,s:integer):integer; var j,rs:integer; begin rs:=1; for j:=1 to s do rs:=rs*r; power:=rs; end; begin readln(n,k); l:=-1; while 2*l<=n do begin inc(l); inc(sum,(c(n-l,l)*power(k-1,n-l))); end; writeln(sum); end. Re: a program Try with Big Numbers, no standart type will pass this problem as far as I remember,otherwise the idea I think is clear |
|
|