1197: [HNOI2006] Flower Fairy Magic time limit:10 Sec Memory limit:162 MB
submit:762 solved:443
[Submit] [Status] Description
Input
Contains two integers, separated by a space, the first integer represents the number of times the magic is applied M, and the second integer represents the dimension n of the space. Among them, 1≤m≤100,1≤n≤15.
Output
Contains only an integer that indicates how many different flowers the flower fairy can get after it implements M magic in n-dimensional space.
Sample Input3 1Sample Output6HINT Source
The puzzle: This is a moe DP ... Transfer: A[i,j]:=a[i,j-1]+a[i-1,j-1], the current I-dimensional j ball, so equal to the result of the former J-1 Ball + the first j-1 to introduce one-dimensional results, the other is not (Hansbug: Man's code so short x bad laugh x)
1 var2 I,j,k,l,n,m:longint;3B:Array[0.. -,0.. +] ofInt64;4 functioncal (X,y:longint): Int64;5 begin6 ifb[x,y]=1 ThenExit (A[x,y]); b[x,y]:=1;7A[x,y]:=cal (x1, Y1) +cal (x,y-1); exit (A[x,y]);8 End;9 beginTen readln (m,n); OneFillchar (b,sizeof (b),0); A fori:=1 toN Do - begin -A[i,1]:=2; B[i,1]:=1; the End; - fori:=1 toM Do - begin -a[1, i]:=2*i;b[1, i]:=1; + End; - Writeln (Cal (N,m)); + End.
1197: [HNOI2006] The magic of the flower Fairy