138 条题解
-
0junhui LV 7 @ 2009-03-03 19:56:28
var
a,b:array[1..1000] of longint;
n,m,i,j,k1,k2:integer;
begin
readln(n,m);
a[1]:=1;
for i:=1 to m do begin
for j:=1 to n do begin
if j-1=0 then k1:=n
else k1:=j-1;
if j+1>n then k2:=1
else k2:=j+1;
b[j]:=a[k1]+a[k2];
end;
a:=b;
end;
writeln(a[1]);
end. -
02009-02-26 15:50:37@
#include
int main(void) {
int i,j,n,m,num[30][31];
scanf("%d%d",&n,&m);
for(num[0][0]=0,num[1][0]=1,i=2;i -
02009-02-18 17:53:32@
顺推或记忆化搜索.
-
02009-02-14 12:55:40@
这个直接交表卅``
-
02009-02-10 20:14:28@
var
a,b,i,j:longint;
f:array[0..30,0..30]of longint;function left(t:longint):longint;
begin
if t=1 then exit(a)else exit(t-1);
end;function right(t:longint):longint;
begin
if t=a then exit(1)else exit(t+1);
end;begin
read(a,b);
f[0,1]:=1;
for i:=1 to b do
for j:=1 to a do
f:=f+f;
writeln(f);
end. -
02009-02-08 17:55:07@
根本不明白。= =
动规没学。
递推不会用。
嗳。
真是人生一大遗憾。
好在我还是个小学生~~
慢慢来,慢慢来…… -
02009-02-02 19:23:08@
#include
int main(void)
{int n,m,i,j,x,y;
int a[40][40]={0};
scanf ("%d %d",&n,&m);
a[0][1]=1;
for (i=1;i -
02009-11-01 17:07:11@
var m,n:longint;
f:array[0..100,1..100] of longint;
i,j:longint;
begin
readln(n,m);
f[0,1]:=1;
for i:=1 to m do
begin
f:=f+f;
for j:=2 to n-1 do
f:=f+f;
f:=f+f;
end;
writeln(f[m,1]);
end. -
02009-01-26 13:54:11@
个人认为这个算不上动归,只能说是递推
-
02009-01-19 11:05:26@
编译通过...
├ 测试数据 01:答案正确... 0ms
├ 测试数据 02:答案正确... 0ms
├ 测试数据 03:答案正确... 0ms
├ 测试数据 04:答案正确... 0ms
├ 测试数据 05:答案正确... 0ms
├ 测试数据 06:答案正确... 0ms
├ 测试数据 07:答案正确... 0ms
├ 测试数据 08:答案正确... 0ms
├ 测试数据 09:答案正确... 0ms
├ 测试数据 10:答案正确... 0ms
---|---|---|---|---|---|---|---|-
Accepted 有效得分:100 有效耗时:0ms -
02009-01-17 18:20:25@
枚举左右:当abs(向左传的次数-向右的) mod n=0时,可以传回来
然后用组合公式求 C(左或右,m) 累加即可
for i:=0 to m do if abs(i-(m-i)) mod n=0 then
begin
t:=i;temp:=1;
for j:=2 to t do temp:=temp / j;
for j:=m downto 1 do temp:=temp*j;
for j:=2 to m-t do temp:=temp / j;
{其实效率很低的}
inc(total,round(temp));
end; -
02009-01-02 10:21:33@
const
maxnm=30;
var
n,m,i,j:integer;
f:array[0..maxnm+1,0..maxnm+1] of longint;
begin
readln(n,m);
fillchar(f,sizeof(f),0);
f[0,1]:=1;f[1,2]:=1;f[1,n]:=1;
for i:=1 to m do
for j:=1 to n do
begin
if j=1
then f:=f+f;
if j=n
then f:=f+f;
if (j>1) and (j -
02008-12-21 14:26:58@
var x,y:array[1..30] of longint;
i,j,n,m:longint;
begin
fillchar(x,sizeof(x),0);
readln(n,m);
x[1]:=1;
for i:=1 to m do
begin
for j:=2 to n-1 do
y[j]:=x[j-1]+x[j+1];
y[1]:=x[n]+x[2];
y[n]:=x[n-1]+x[1];
x:=y;
end;
writeln(x[1]);
end. -
02008-12-21 13:36:52@
矩阵乘法。。。。
O(n^3*log M) -
02008-12-19 22:49:58@
编译通过...
├ 测试数据 01:答案正确... 0ms
├ 测试数据 02:答案正确... 0ms
├ 测试数据 03:答案正确... 0ms
├ 测试数据 04:答案正确... 0ms
├ 测试数据 05:运行超时...
├ 测试数据 06:运行超时...
├ 测试数据 07:运行超时...
├ 测试数据 08:运行超时...
├ 测试数据 09:运行超时...
├ 测试数据 10:运行超时...
---|---|---|---|---|---|---|---|-
Unaccepted 有效得分:40 有效耗时:0ms搜死了6个
-
02008-12-16 14:38:51@
var m,n:longint;
f:array[0..100,1..100] of longint;
i,j:longint;
begin
readln(n,m);
f[0,1]:=1;
for i:=1 to m do
begin
f:=f+f;
for j:=2 to n-1 do
f:=f+f;
f:=f+f;
end;
writeln(f[m,1]);
end. -
02008-12-12 20:06:51@
var f:Array[0..30,1..30]of longint;
i,j,k,l,m,n:longint;
begin
readln(n,m);
f[0,1]:=1;
for i:=1 to m do
begin
f:=f+f;
for j:=2 to n-1 do
f:=f+f;
f:=f+f;
end;
writeln(f[m,1]);
end.今年没打close的题。
-
02008-12-09 18:55:15@
编译通过...
-
02008-12-08 13:50:41@
普及组真的狠简单
弱弱的DP
-
02008-12-08 13:40:10@
program p1485;
var
f:array[1..30,0..30] of longint;
n,m,i,j:integer;
begin
fillchar(f,sizeof(f),0);
readln(n,m);
f[1,0]:=1;
for i:=1 to m do
for j:=1 to n do
begin
if j=1 then f[j,i]:=f[n,i-1]+f[j+1,i-1]
else if j=n then f[j,i]:=f[1,i-1]+f[j-1,i-1]
else f[j,i]:=f[j-1,i-1]+f[j+1,i-1];
end;
writeln(f[1,m]);
end.