题解

294 条题解

  • 0
    @ 2009-11-18 20:32:36

    编译通过...

    ├ 测试数据 01:答案正确... 41ms

    ├ 测试数据 02:答案正确... 0ms

    ├ 测试数据 03:答案正确... 0ms

    ├ 测试数据 04:答案正确... 0ms

    ├ 测试数据 05:答案正确... 0ms

    ├ 测试数据 06:答案正确... 0ms

    ├ 测试数据 07:答案正确... 0ms

    ├ 测试数据 08:答案正确... 0ms

    ├ 测试数据 09:答案正确... 650ms

    ├ 测试数据 10:答案正确... 806ms

    ---|---|---|---|---|---|---|---|-

    Accepted 有效得分:100 有效耗时:1497ms

    裸搜

  • 0
    @ 2009-11-09 21:13:38

    没有优化,給我的第200次提交打了个超时……

    到了第202次终于AC了

    题目简单,记得优化

  • 0
    @ 2009-11-08 08:59:16

    program mlghz;

    var

    a:array[-2..17,-2..17] of longint;

    b:array[-2..17,-2..17] of boolean;

    bx,by,mx,my,i,j:longint;

    begin

    readln(bx,by,mx,my);

    for i:=-2 to 17 do

      for j:=-2 to 17 do

       begin

        a:=0;

        b:=false;

       end;

    b[mx,my]:=true;

    b[mx-1,my+2]:=true;

    b[mx-1,my-2]:=true;

    b[mx-2,my+1]:=true;

    b[mx-2,my-1]:=true;

    b[mx+1,my+2]:=true;

    b[mx+1,my-2]:=true;

    b[mx+2,my+1]:=true;

    b[mx+2,my-1]:=true;

    a[0,0]:=1;

    for i:=1 to by do

      if not b[0,i] then a[0,i]:=1

      else break;

    for i:=1 to bx do

      if not b then a:=1

      else break;

    for i:=1 to bx do

      for j:=1 to by do

       if b then

       else

        a:=a+a;

    writeln(a[bx,by]);

    end.

  • 0
    @ 2009-11-07 12:50:15

    #include

    using namespace std;

    int m,n,x,y;

    int map[16][16];

    inline int abs(int n)

    {if(n>x>>y;

    for(int i=0;i

  • 0
    @ 2009-11-06 19:57:32

    感觉真的很失败!边界条件没有考虑清楚,害我交了n次啊,细节细节啊

  • 0
    @ 2009-11-04 19:28:08

    program mlghz;

    var

    a:array[-2..17,-2..17] of longint;

    b:array[-2..17,-2..17] of boolean;

    bx,by,mx,my,i,j:longint;

    begin

    readln(bx,by,mx,my);

    for i:=-2 to 17 do

    for j:=-2 to 17 do

    begin

    a:=0;

    b:=false;

    end;

    b[mx,my]:=true;

    b[mx-1,my+2]:=true;

    b[mx-1,my-2]:=true;

    b[mx-2,my+1]:=true;

    b[mx-2,my-1]:=true;

    b[mx+1,my+2]:=true;

    b[mx+1,my-2]:=true;

    b[mx+2,my+1]:=true;

    b[mx+2,my-1]:=true;

    a[0,0]:=1;

    for i:=1 to by do

    if not b[0,i] then a[0,i]:=1

    else break;

    for i:=1 to bx do

    if not b then a:=1

    else break;

    for i:=1 to bx do

    for j:=1 to by do

    if b then

    else

    a:=a+a;

    writeln(a[bx,by]);

    end.

    我发誓:

    以后一定用longint代替integer!!!!!!!!!

  • 0
    @ 2009-11-04 18:52:30

    var

    by,bx,cy,cx,i,j : longint;

    a : array[0..20,0..20]of boolean;

    f : array[0..20,0..20]of qword;

    begin

    readln(bx,by,cx,cy);

    fillchar(a,sizeof(a),true);

    a[cx,cy]:=false;

    if (cx-1>=0)and(cy-2>=0) then a[cx-1,cy-2]:=false;

    if (cx-1>=0)and(cy+2=0)and(cy+1

  • 0
    @ 2009-11-02 19:47:12

    编译通过...

    ├ 测试数据 01:答案正确... 0ms

    ├ 测试数据 02:答案正确... 0ms

    ├ 测试数据 03:答案正确... 0ms

    ├ 测试数据 04:答案正确... 0ms

    ├ 测试数据 05:答案正确... 0ms

    ├ 测试数据 06:答案正确... 0ms

    ├ 测试数据 07:答案正确... 0ms

    ├ 测试数据 08:答案正确... 0ms

    ├ 测试数据 09:答案正确... 0ms

    ├ 测试数据 10:答案正确... 0ms

    ---|---|---|---|---|---|---|---|-

    Accepted 有效得分:100 有效耗时:0ms

    秒杀水题

    const

    tx:array[1..8]of longint=(-2,-1,1,2,2,1,-1,-2);

    ty:array[1..8]of longint=(1,2,2,1,-1,-2,-2,-1);

    var

    n,m,x,y,i,j:longint;

    g:array[-2..25,-2..25]of longint;

    f:array[0..21,0..21]of qword;

    begin

    readln(n,m,x,y);

    for i:=-2 to 23 do

    for j:=-2 to 23 do

    if (i=0) and (j=0)

    then g:=0

    else g:=1;

    g[x,y]:=1;

    for i:=1 to 8 do

    g[x+tx[i],y+ty[i]]:=1;

    fillchar(f,sizeof(f),0);

    f[0,0]:=1;

    for i:=1 to n do

    if (g=0) then f:=f;

    for i:=1 to m do

    if (g[0,i]=0) then f[0,i]:=f[0,i-1];

    for i:=1 to n do

    for j:=1 to m do

    if (g=0) then

    begin

    f:=f+f;

    end;

    writeln(f[n,m]);

    end.

  • 0
    @ 2009-11-01 21:48:39

    program p1121;

    var

    n,m,a,b,i,j:integer;

    f:array[-2..17,-2..17]of longint;

    function max(a,b:longint):longint;

    begin

    if a>b

    then max:=a

    else max:=b;

    end;

    begin

    fillchar(f,sizeof(f),0);

    readln(n,m,a,b);

    f[a,b]:=-1;

    f[a-1,b+2]:=-1;

    f[a-1,b-2]:=-1;

    f[a-2,b+1]:=-1;

    f[a-2,b-1]:=-1;

    f[a+1,b-2]:=-1;

    f[a+1,b+2]:=-1;

    f[a+2,b-1]:=-1;

    f[a+2,b+1]:=-1;

    for i:=1 to n do

    if f-1

    then f:=1

    else break;

    for j:=1 to m do

    if f[0,j]-1

    then f[0,j]:=1

    else break;

    for i:=1 to n do

    for j:=1 to m do

    if f-1

    then f:=max(f,0)+max(f,0);

    writeln(max(f[n,m],0));

    end.

  • 0
    @ 2009-10-29 16:48:30

    var q,g:array [-2..10000,-2..10000] of longint;

    n,m,i,j,a,b:integer;

    begin

    readln(n,m,a,b);

    q[0,0]:=1;

    g[a,b]:=-1;

    g[a+1,b+2]:=-1;

    g[a+2,b+1]:=-1;

    g[a-1,b+2]:=-1;

    g[a-2,b+1]:=-1;

    g[a+1,b-2]:=-1;

    g[a+2,b-1]:=-1;

    g[a-1,b-2]:=-1;

    g[a-2,b-1]:=-1;

    for i:=0 to n do

    for j:=0 to m do

    if (g-1) and ((i0)or(j0)) then q:=q+q;

    writeln(q[n,m]);

    end.

  • 0
    @ 2009-10-28 22:47:47

    program v1121;

    var

    f:array[0..20,0..20]of int64;

    b1:array[0..20,0..20]of boolean;

    n,m,a,b,i,j:longint;

    begin

    read(n,m,a,b);

    b1[a,b]:=true;

    if (a-2>=0)and(b-1>=0) then b1[a-2,b-1]:=true;

    if (a-1>=0)and(b-2>=0) then b1[a-1,b-2]:=true;

    if (a+1=0) then b1[a+1,b-2]:=true;

    if (a+2=0) then b1[a+2,b-1]:=true;

    if (a+2

  • 0
    @ 2009-10-27 17:20:05

    #include

    int dp[20][20]={0};

    int n,m;

    int x,y;

    void dfs(int x1,int y1)

    {

    if(dp[x1][y1]>0) return ;

    else

    {

    if(abs(x-x1)==2&&abs(y1-y)==1)

    return ;

    if(abs(x-x1)==1&&abs(y1-y)==2)

    return ;

    if(x==x1&&y==y1)

    return ;

    else

    if(x1>0) dfs(x1-1,y1);

    if(y1>0) dfs(x1,y1-1);

    dp[x1][y1]=dp[x1-1][y1]+dp[x1][y1-1];

    return ;

    }

    }

    int main()

    {

    scanf("%d%d",&n,&m);

    scanf("%d%d",&x,&y);

    dp[0][0]=1;

    dfs(n,m);

    printf("%ld\n",dp[n][m]);

    }

  • 0
    @ 2009-10-27 17:01:50

    My solutionprogram asfas;const p:array[1..8] of shortint=(2,-2,-1,-1,1,1,-2,2); q:array[1..8] of shortint=(-1,1,-2,2,-2,2,-1,1);var a,f:array[0..20,0..20] of int64; x,y,m,n:int64; i,j:longint;begin read(x,y,m,n); fillchar(a,sizeof(a),0); a[m,n]:=1; for i:=1 to 8 do if (m+p[i]>=0)and(n+q[i]>=0) then a[m+p[i],n+q[i]]:=1; f[0,0]:=1; for i:=1 to x do if a1 then f:=f else f:=0; for j:=1 to y do if a[0,j]1 then f[0,j]:=f[0,j-1] else f[0,j]:=0; for i:=1 to x do for j:=1 to y do if a1 then f:=f+f else f:=0; writeln(f[x,y]);end.

  • 0
    @ 2009-10-23 23:36:01

    原题是要高精加和滚动数组的啊……

    结果高精没调对,边界值也出问题,调了半天……

    题水人更水……

    const

    dx:array[1..8]of integer=(-2,-1,1,2,2,1,-1,-2);

    dy:array[1..8]of integer=(-1,-2,-2,-1,1,2,2,1);

    var

    a:array[0..50,0..50]of boolean;

    f:array[-1..50,-1..50]of longint;

    i,j,k,l,x,y,n,m,n1,m1:longint;

    begin

    readln(n,m,n1,m1);

    fillchar(a,sizeof(a),true);

    a[n1,m1]:=false;

    for i:=1 to 8 do

    begin

    x:=n1+dx[i];

    y:=m1+dy[i];

    if (x>=0)and(x=0)and(yb[0] then len:=a[0]

    else len:=b[0];

    k:=0;

    for i:=1 to len do

    begin

    c[i]:=k+a[i]+b[i];

    k:=c[i] div 10;

    c[i]:=c[i] mod 10;

    end;

    while k>0 do begin inc(len); c[len]:=k mod 10; k:=k div 10; end;

    c[0]:=len;

    end;

    begin

    readln(n,m,n1,m1);

    fillchar(a,sizeof(a),true);

    a[n1,m1]:=false;

    for i:=1 to 8 do

    begin

    x:=n1+dx[i];

    y:=m1+dy[i];

    if (x>=0)and(x=0)and(y0 do begin write(f[m][len]); dec(len); end;

    end.

  • 0
    @ 2009-10-21 10:54:32

    const

    x:array[1..8] of shortint=(-1,-1,-2,-2,2,2,1,1);

    y:array[1..8] of shortint=(2,-2,1,-1,1,-1,2,-2);

    var

    map:array[-1..15,-1..15] of longint;

    m,n,a,b,i,j:longint;

    begin

    readln(m,n,a,b);

    for i:=1 to 8 do

    if (a+x[i]in[0..m]) and (b+y[i]in[0..n]) then

    map[a+x[i],b+y[i]]:=-1;

    map[0,0]:=1;

    map[a,b]:=-1;

    for i:=0 to m do

    for j:=0 to n do

    if map-1 then

    begin

    if map-1 then inc(map,map);

    if map-1 then inc(map,map);

    end;

    if map[m,n]=-1 then write(0) else write(map[m,n]);

    end.

    很郁闷……竟然因为longint的问题多提交了一次……大家要注意啊

  • 0
    @ 2009-10-14 22:30:55

    喜欢记忆化搜索!

    program Vijos1121;

    var

    x,y,mx,my:longint;

    map:array[-5..20,-5..20]of longint;

    hash:array[-5..20,-5..20]of boolean;

    function dfs(xx,yy:longint):longint;

    begin

    if (xxx)or(yyy) then exit(0);

    if not hash[xx,yy] then exit(0);

    if map[xx,yy]0 then exit(map[xx,yy]);

    map[xx,yy]:=dfs(xx-1,yy)+dfs(xx,yy-1);

    exit(map[xx,yy]);

    end;

    begin

    readln(x,y,mx,my);

    fillchar(map,sizeof(map),0);

    fillchar(hash,sizeof(hash),true);

    map[0,0]:=1;

    hash[mx,my]:=false;

    hash[mx-2,my+1]:=false;

    hash[mx-1,my+2]:=false;

    hash[mx+1,my+2]:=false;

    hash[mx+2,my+1]:=false;

    hash[mx+2,my-1]:=false;

    hash[mx+1,my-2]:=false;

    hash[mx-1,my-2]:=false;

    hash[mx-2,my-1]:=false;

    writeln(dfs(x,y));

    end.

    编译通过...

    ├ 测试数据 01:答案正确... 0ms

    ├ 测试数据 02:答案正确... 0ms

    ├ 测试数据 03:答案正确... 0ms

    ├ 测试数据 04:答案正确... 0ms

    ├ 测试数据 05:答案正确... 0ms

    ├ 测试数据 06:答案正确... 0ms

    ├ 测试数据 07:答案正确... 0ms

    ├ 测试数据 08:答案正确... 0ms

    ├ 测试数据 09:答案正确... 0ms

    ├ 测试数据 10:答案正确... 0ms

    ---|---|---|---|---|---|---|---|-

    Accepted 有效得分:100 有效耗时:0ms

  • 0
    @ 2009-10-13 22:10:47

    var

    f:array[0..15,0..15]of longint;

    n:array[-1..16,-1..16]of boolean;

    bi,bj,ci,cj:longint;

    procedure change;

    begin

    n[ci,cj]:=false;

    n[ci-2,cj-1]:=false;

    n[ci+2,cj-1]:=false;

    n[ci-2,cj+1]:=false;

    n[ci+2,cj+1]:=false;

    n[ci-1,cj-2]:=false;

    n[ci+1,cj-2]:=false;

    n[ci-1,cj+2]:=false;

    n[ci+1,cj+2]:=false;

    end;

    function dfs(x,y:longint):longint;

    begin

    if f[x,y]-1 then exit(f[x,y])

    else

    begin

    f[x,y]:=0;

    if n[x,y+1] and (y+1

  • 0
    @ 2009-10-15 16:25:56

    第三组注意判断临界边上的...

    #include

    int map[16][16]={0};

    long int mm[16][16]={0};

    int x,y;

    void horse(int m,int n)

    {

    int a=1,b=2;

    if((0

  • 0
    @ 2009-10-07 14:41:36

    秒杀

    编译通过...

    ├ 测试数据 01:答案正确... 0ms

    ├ 测试数据 02:答案正确... 0ms

    ├ 测试数据 03:答案正确... 0ms

    ├ 测试数据 04:答案正确... 0ms

    ├ 测试数据 05:答案正确... 0ms

    ├ 测试数据 06:答案正确... 0ms

    ├ 测试数据 07:答案正确... 0ms

    ├ 测试数据 08:答案正确... 0ms

    ├ 测试数据 09:答案正确... 0ms

    ├ 测试数据 10:答案正确... 0ms

    ---|---|---|---|---|---|---|---|-

    Accepted 有效得分:100 有效耗时:0ms

    var

    map:array[0..20,0..20] of boolean;

    f:array[0..20,0..20] of int64;

    n,m,x,y,i,j:longint;

    begin

    readln(m,n,y,x);

    fillchar(map,sizeof(map),true);

    map[x,y]:=false;

    map[x+1,y+2]:=false;

    map[x+2,y+1]:=false;

    map[x-1,y-2]:=false;

    map[x-2,y-1]:=false;

    map[x+1,y-2]:=false;

    map[x+2,y-1]:=false;

    map[x-1,y+2]:=false;

    map[x-2,y+1]:=false;

    f[0,0]:=1;

    for i:=1 to n do

    begin

    if not map then break;

    f:=1;

    end;

    for i:=1 to m do

    begin

    if not map[0,i] then break;

    f[0,i]:=1;

    end;

    for i:=1 to n do

    for j:=1 to m do

    if map then

    begin

    if map then

    f:=f+f;

    if map then

    f:=f+f;

    end;

    writeln(f[n,m]);

    end.

  • 0
    @ 2009-10-05 14:19:50

    DP:

    var

    n,m,x,y,i,j:longint;

    d:array[-2..100,-2..100] of longint;

    ok:array[-2..100,-2..100] of boolean;

    begin

    readln(n,m,x,y);

    fillchar(ok,sizeof(ok),true);

    ok[x+2,y+1]:=false;

    ok[x+2,y-1]:=false;

    ok[x-2,y+1]:=false;

    ok[x-2,y-1]:=false;

    ok[x+1,y+2]:=false;

    ok[x+1,y-2]:=false;

    ok[x-1,y+2]:=false;

    ok[x-1,y-2]:=false;

    ok[x,y]:=false;

    d[0,0]:=1;

    for i:=1 to n do if ok then d:=1 else break;

    for i:=1 to m do if ok[0,i] then d[0,i]:=1 else break;

    for i:=1 to n do

    for j:=1 to m do

    if ok then

    d:=d+d;

    writeln(d[n,m]);

    end.

信息

ID
1121
难度
4
分类
动态规划 点击显示
标签
递交数
9582
已通过
3785
通过率
40%
被复制
24
上传者