题解

294 条题解

  • 0
    @ 2009-05-19 13:27:20

    var

    a:array[-5..50,-5..50] of longint;

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

    begin

    readln(m,n,x,y);

    a[x,y]:=-1;

    a[x-2,y-1]:=-1;

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

    a[x-1,y-2]:=-1;

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

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

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

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

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

    for i:=0 to n do

    if a[0,i]=-1 then break else a[0,i]:=1;

    for i:=0 to m do

    if a=-1 then break else a:=1;

    for i:=0 to n do

    if a[0,i]=-1 then a[0,i]:=0;

    for i:=0 to m do

    if a=-1 then a:=0;

    for i:=1 to m do

    for j:=1 to n do

    if a=-1 then a:=0 else a:=a+a;

    writeln(a[m,n]);

    end.

  • 0
    @ 2009-05-16 08:57:41

    #include

    using namespace std;

    int main()

    {

    int n,m,h,l,i,j;

    cin>>n>>m>>h>>l;

    int b[n+1][m+1];

    for(i=0;i

  • 0
    @ 2009-05-09 13:44:47

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

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

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

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

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

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

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

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

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

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

    #include

    using namespace std;

    int main()

    {

    int n,m,h,l,i,j;

    cin>>n>>m>>h>>l;

    int a[n+1][m+1];

    for(i=0;i

  • 0
    @ 2009-04-24 15:24:54

    #include

    using namespace std;

    int main(void)

    {

    int n,m,a,b,i,j,k;

    __int64 d[20][20];

    int c[2][2]={{0,1},{1,0}};

    while(cin>>n>>m>>a>>b)

    {

    for(i=0;i

  • 0
    @ 2009-04-23 13:10:26

    动态规划 可以么?

  • 0
    @ 2009-04-23 13:04:32

    各位大牛,我的程序就是超时,想了好久,不晓得怎么给这道题加记忆化,哪位大牛指点一下啊

    #include

    #include

    int x1[9]={0,1,2,2,1,-1,-2,-2,-1};

    int y1[9]={0,-2,-1,1,2,2,1,-1,-2};

    int d[9][2],map[15][15];

    int count=0,ct=1,xz,yz;

    void f(int,int);

    int cmp(int,int);

    void find(int x,int y);

    main()

    {

    int xm,ym;

    scanf ("%d %d %d %d",&xz,&yz,&xm,&ym);

    find(xm,ym);

    f(0,0);

    printf ("%d",count);

    system("pause");

    }

    void find(int x,int y)

    {

    int i;

    d[0][0]=x;d[0][1]=y;

    for (i=1;i=0&&(x+x1[i])

  • 0
    @ 2009-04-05 19:04:25

    回顾经典搜索..

    宣传BLOG:http://hi.baidu.com/x50946702

    欢迎大牛来BS我.....评论有奖,留言无罪......

    program p1121;

    var

    a:array[-15..30,-15..30]of longint;

    s:array[-15..30,-15..30]of boolean;

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

    procedure chushihua;

    begin

    for i:=0 to n do

    for j:=0 to m do

    begin

    a:=0;

    s:=true;

    end;

    s[x,y]:=false;

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

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

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

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

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

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

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

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

    a[0,0]:=1;

    for i:=1 to n do

    if (a0)and(s) then a:=1;

    for j:=1 to m do

    if (a[0,j-1]0)and(s[0,j]) then a[0,j]:=1;

    end;

    procedure init;

    begin

    readln(n,m,x,y);

    chushihua;

    end;

    procedure doit;

    begin

    for i:=1 to n do

    for j:=1 to j do

    if s then a:=a+a;

    end;

    procedure outit;

    begin

    writeln(a);

    end;

    begin

    init;

    doit;

    outit;

    end.

  • 0
    @ 2009-04-05 16:28:34

    编译通过...

    ├ 测试数据 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-05-06 18:53:03

    编译通过...

    ├ 测试数据 01:答案似乎正确... 1ms

    ├ 测试数据 02:答案也许正确... 4ms

    ├ 测试数据 03:答案好像正确... 3ms

    ├ 测试数据 04:答案仿佛正确... 8ms

    ├ 测试数据 05:答案可能正确... 8ms

    ├ 测试数据 06:答案大概正确... 8ms

    ├ 测试数据 07:答案或许正确... 5ms

    ├ 测试数据 08:答案貌似正确... 8ms

    ├ 测试数据 09:答案近乎正确... 7ms

    ├ 测试数据 10:答案看起来正确... 4ms

    可能是100,不过不保证是0.命运之神保佑你!祝你好运!!!!!!!!

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

    var i,j,n,m:longint; t:int64;

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

    procedure dfs(x,y:longint);

    begin

    if (x=n) and (y=m) then begin inc(t); exit; end;

    if (a[x+1,y]=0) and (x

  • 0
    @ 2009-03-18 13:10:14

    递推题

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

    x:array[0..17,0..17]of boolean;

    b1,b2,z1,z2,i,j:longint;

    begin

    readln(b1,b2,z1,z2);

    a[0,0]:=1;

    x[z1,z2]:=true;

    x[z1-2,z2-1]:=true;

    x[z1-1,z2-2]:=true;

    x[z1+2,z2-1]:=true;

    x[z1+1,z2-2]:=true;

    x[z1-2,z2+1]:=true;

    x[z1-1,z2+2]:=true;

    x[z1+1,z2+2]:=true;

    x[z1+2,z2+1]:=true;

    x[z1,z2]:=true;

    for i:=0 to b1 do

    for j:=0 to b2 do

    begin if not(x)then a:=a+a+a; end;

    writeln(a[b1,b2]);

    end.

  • 0
    @ 2009-03-10 17:32:36

    WATER......WATER.......

  • 0
    @ 2009-02-22 20:06:40

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

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

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

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

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

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

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

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

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

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

  • 0
    @ 2009-02-22 14:33:37

    编译通过...

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

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

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

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

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

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

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

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

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

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

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

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

    program asd;

    var d,a,b,x,y,i,j:integer; ab:array [-2..15,-2..15] of longint;

    begin

    read(a,b,x,y);

    for i:=0 to a do

    for j:=0 to b do

    ab:=0;

    ab[x-1,y-2]:=-1;

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

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

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

    ab[x-2,y-1]:=-1;

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

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

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

    ab[x,y]:=-1;

    d:=1;

    for i:=1 to a do

    if ab-1 then

    ab:=d

    else d:=-1;

    d:=1;

    for i:=1 to b do

    if ab[0,i]-1 then

    ab[0,i]:=d

    else d:=-1;

    for i:=1 to a do

    for j:=1 to b do

    if ab-1 then

    begin

    if ab-1 then ab:=ab+ab;

    if ab-1 then ab:=ab+ab;

    end;

    writeln(ab[a,b]);

    end.

  • 0
    @ 2009-02-11 19:18:45

    #include

    using namespace std;

    const int MAX = 20;

    int chess[MAX][MAX];

    int hx[8] = {1,2, 2, 1,-1,-2,-2,-1,};

    int hy[8] = {2,1,-1,-2,-2,-1, 1, 2,};

    int sum;

    int n,m;

    int sx,sy;

    void solve(int i,int j){

    if(sx>=i&&sy>=j&&chess[i][j] == 0){

    solve(i+1,j);

    solve(i,j+1);

    }else{

    if(chess[i][j] == 2){

    sum++;

    }

    }//end for if

    }//end for solve

    void initiliate(int i,int j){

    chess[i][j] = 1;

    int pi = i;

    int pj = j;

    for(int h=0;h=0&&16>pi&&pj>=0&&16>pj)

    chess[pi][pj] = 1;

    }

    }//end for initiliate

    int main(){

    sum = 0;

    cin>>sx>>sy>>m>>n;

    for(int i=0;i

  • 0
    @ 2009-02-09 00:15:55

    #include

    using namespace std;

    main()

    {

    bool map[16][16];

    memset(map,true,sizeof(map));

    int n,m,x,y;

    cin>>n>>m>>x>>y;

    if (x+2=0) {

    if (y+1=0) map[x-2][y-1]=false;

    }

    if (x-1>=0) {

    if (y+2=0) map[x-1][y-2]=false;

    }

    if (x+10) f[i][k-i]+=f[k-i];

    if (k>i) f[i][k-i]+=f[i][k-i-1];

    }

    cout

  • 0
    @ 2009-02-05 11:56:18

    原来马在的那个点也不能走……

    白思考了半天……

  • 0
    @ 2009-02-02 02:14:15

    编译通过...

    ├ 测试数据 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-01-26 18:27:47

    明白了……第三个点得加个处理……

    比如一个点上面的和左面的都是f那么他也是f。(有个什么经典的问题叫……走迷宫?)

    一道简单的DP竟然让我耗费了3次!我的AC率!!!

    {————————————————————————————}

    编译通过...

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

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

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

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

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

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

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

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

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

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

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

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

    var

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

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

    v:array[-1..17,-1..17]of boolean;

    begin

    read(n,m,x,y);

    fillchar(a,sizeof(a),0);

    fillchar(v,sizeof(v),true);

    for i:=1 to n do a:=1;

    for i:=1 to m do a[0,i]:=1;

    v[x,y]:=false;

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

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

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

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

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

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

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

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

    for i:=-1to n do

    v:=false;

    for i:=-1 to m do

    v[-1,i]:=false;

    v[-1,0]:=true;

    for i:=0 to n do

    for j:=0 to m do

    if (not v) and (not v) then v:=false;

    for i:=1 to n do

    for j:=1 to m do

    if v then

    begin

    if not v then t1:=0 else t1:=a;

    if not v then t2:=0 else t2:=a;

    a:=t1+t2;

    end;

    writeln(a[n,m]);

    end.

    Flag    Accepted

    题号   P1121

    类型(?)   搜索

    通过   3796人

    提交   9217次

    通过率   41%

    难度   1

    提交 讨论 题解

    囧……这是怎么了?

    编译通过...

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

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

    ├ 测试数据 03:答案错误...程序输出比正确答案长

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

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

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

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

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

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

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

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

    Unaccepted 有效得分:90 有效耗时:0ms

    var

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

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

    v:array[-1..17,-1..17]of boolean;

    begin

    read(n,m,x,y);

    fillchar(a,sizeof(a),0);

    fillchar(v,sizeof(v),true);

    for i:=0 to n do a:=1;

    for i:=0 to m do a[0,i]:=1;

    v[x,y]:=false;

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

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

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

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

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

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

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

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

    for i:=1 to n do

    for j:=1 to m do

    if v then

    begin

    if not v then t1:=0 else t1:=a;

    if not v then t2:=0 else t2:=a;

    a:=t1+t2;

    end;

    writeln(a[n,m]);

    end.

    Flag    Unaccepted

    题号   P1121

    类型(?)   搜索

    通过   3795人

    提交   9209次

    通过率   41%

    难度   1

    提交 讨论 题解

  • 0
    @ 2009-01-15 13:12:39

    编译通过...

    ├ 测试数据 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-01-11 13:31:24

    var a:array[-2..18,-2..18] of boolean;t:qword;n,m,i,j:integer;

    procedure go(i,j:integer); {搜索路径的递归}

    begin

    if a then exit; {走到了不该走的地方...(会吃掉马或者被马吃掉)}

    if (i=n) and (j=m) then inc(t) else {如果到目的地了,方法数就+1}

      begin

       if (i+1)

信息

ID
1121
难度
4
分类
动态规划 点击显示
标签
递交数
9572
已通过
3779
通过率
39%
被复制
23
上传者