Filippov Nickolas SSAU#2's AC program is HERE!
program staircases;
var a:array[0..500] of extended;
n,i,j:longint;
begin
read(n);
fillchar(a,sizeof(a),0); a[0]:=1;
for j:=1 to n do
for i:=n downto j do a[i]:=a[i]+a[i-j];
a[n]:=a[n]-1;
writeLn(a[n]:0:0);
end.
Re: Filippov Nickolas SSAU#2's AC program is HERE!
Послано
xdex 21 мар 2003 16:02
pls explain ur algorithm i.e. write down recurrent equation that it
use ...
Re: Filippov Nickolas SSAU#2's AC program is HERE!
Послано
Cosine 13 авг 2003 11:30
What does F(n) mean in your programme?
Re: Filippov Nickolas SSAU#2's AC program is HERE!
Thank Nickolas.
I didn't see his carefully, just a look. To my surprise it is so short. Suddenly I found a good way to solve this problem -- When I got AC , I found it looks like his one very much...
We can get f(m,n) = f(m,n-1) + f(m-n,n-1) easily
(Sorry my English isn't good enough to explain what m & n are.)
Notice that f(...,n) is based on f(...,n-1)
Then, we can get a good program.
Time : O(n^2)
Memory : O(n)
Thanks!
Hi! Remember me? [I was an Evil Hacker]
email me: oberon at verba.com.ua
Re: Filippov Nickolas SSAU#2's AC program is HERE!
Послано
ling 2 июн 2004 17:35
Oh,that is easy to understand!
In fact,it's multinomial multiplication,and I think it's just (1+x)*(1+x^2)*(1+x^3)...... Is that right?
Re: Filippov Nickolas SSAU#2's AC program is HERE!
Послано
Sid 21 мар 2005 23:41
I solved this problem another way... But your program is perfect... can you explain how did you invent it?
Re: Filippov Nickolas SSAU#2's AC program is HERE!
Послано
visio 3 апр 2005 04:15
My solution is fast! valery@uni.lg.ua
Edited by author 03.04.2005 04:15