题解

144 条题解

  • 0
    @ 2008-09-18 18:17:25

    编译通过...

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

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

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

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

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

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

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

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

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

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

    太高兴了··· 1次AC

    哈哈···自己弄了个构造法AC···

    。。。。。。。。。。

  • 0
    @ 2008-09-18 17:48:43

    超时

  • 0
    @ 2008-09-17 23:21:18

    20的阶乘开什么了?

    QWORD????

    我写高精。。。

  • 0
    @ 2008-09-14 11:06:51

    汗用了Longint错了N次

  • 0
    @ 2008-09-11 22:58:19

    var n,m,i,j,p,t:longword;

    a:array[0..20] of qword;

    c:array[1..20] of byte;

    re:array[0..20] of boolean;

    begin

    readln(n,m); a[0]:=1;

    for i:= 1 to n do

    begin

    a[i]:=1;

    for j:= 1 to i do

    a[i]:=a[i]*j;

    end;

    for i:=1 to n do

    begin

    t:=((m-1)div a[n-i]+1)mod (n-i+1);

    if t=0 then t:=n-i+1;

    p:=0;

    for j:=1 to n do

    begin

    if not re[j] then inc(p);

    if p=t then break;

    end;

    c[i]:=j;

    re[j]:=true;

    end;

    for i:= 1 to n do write(c[i],' ');

    end.

    迷迷糊糊得用所谓构造法过了。。。但是,希望有大大能发下完整的推导过程,谢谢

  • 0
    @ 2008-09-10 19:50:16

    编译通过...

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

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

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

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

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

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

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

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

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

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

    过了,哈哈

  • 0
    @ 2008-09-09 19:46:49

    var

    i,j,k,s:longint;

    a,b:array[1..20]of longint;

    x:array[1..20]of boolean;

    n,e,m:qword;

    function jie(q:qword):qword;

    var

    i,k:longint;

    begin

    jie:=1;

    for i:=1 to q do

    jie:=jie*i;

    end;

    begin

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

    fillchar(x,sizeof(x),true);

    readln(n,m);

    i:=1;

    e:=jie(n-i);

    repeat

    for k:=1 to n do

    if x[k]

    then if e

  • 0
    @ 2008-09-06 14:25:38

    算法思想:先找n个数的第k种全排列的第一个数,再找剩下n-1个数第k种全排列的第一个数......依此类推。

    核心代码:

    if k mod sum=0 then

    i:=k div sum

    else i:=k div sum+1;

    l:=1;

    p:=0;

    i:=i mod (n-j+1);

    if i=0 then i:=n-j+1;

    repeat

    if a[l] then inc(p);

    inc(l);

    until p>=i;

    write(l-1,' ');

    a[l-1]:=false;

    0msAC.

  • 0
    @ 2008-09-05 22:23:31

    var

    n,t:longint;

    m:int64;

    a:array[1..20] of integer;

    flag:array[1..20] of boolean;

    procedure search(depth:integer);

    var

    i:integer;

    begin

    if(depth>n) then

    begin

    inc(t);

    if t=m then

    begin

    write(a[1]);

    for i:=2 to n do write(a[i]:2);

    end;

    exit;

    end;

    for i:=1 to n do

    if flag[i]=false then

    begin

    a[depth]:=i;

    flag[i]:=true;

    search(depth+1);

    flag[i]:=false;

    end;

    end;

    begin

    readln(n,m);

    t:=0;

    fillchar(flag,sizeof(flag),false);

    search(1);

    end.

  • 0
    @ 2008-08-28 19:36:10

    cantor展开 倒着来??

    f 处理的这段的第一位数是从未用的数中第1到i大的数 后面接着j个数 是可以排多少种

    若 f>=m 则 可以放第i大的数到该位 同时 在第i+1到n位 排出第 m-f大的数即可

  • 0
    @ 2008-08-28 09:09:31

    我也用置换做的为什么也62?它超时。。。。。。。哪位大牛可以教一下

  • 0
    @ 2009-02-12 07:51:31

    请看3的全排列:

    1 2 3

    1 3 2

    2 1 3

    2 3 1

    3 1 2

    3 2 1

    再看4的全排列 尤其是括号部分:

    1 (2 3 4)

    1 (2 4 3)

    1 (3 2 4)

    1 (3 4 2)

    1 (4 2 3)

    1 (4 3 2)

    2 ……

    3 ……

    可见n+1的全排列 2--n+1 部分 与 n的全排列的顺序(不是数)一致

    通过这个规律也可AC 0ms

  • 0
    @ 2008-08-25 17:01:28

    数据弱了....我4 6 都没出来就AC了

  • 0
    @ 2008-08-22 16:38:28

    突然发现一个一直存在的问题,C的数组20,其实是0..19,习惯了Pascal,所以每次一到最大数据的时候总少一,啊,郁闷到了。难怪前几天的题要把范围改大点才能过。

  • 0
    @ 2008-08-20 09:12:41

    解释一下楼下的代码

    see[i]表示i是否可用,初始为true

    s[i]=i!

  • 0
    @ 2008-08-19 16:54:54

    看了大牛的结题报告后一次AC

  • 0
    @ 2008-08-10 16:24:31

    为什么用生成法

    也会超时

  • 0
    @ 2008-01-09 14:09:11

    本题采用递归回溯(以4为例)

    先入栈

    a[0]=1,a[1]=1+1,a[2]=1+1+1,a[3]=1+1+1+1,top=3;

    回溯

    top=2,a[2]=3+1=4,top=3,a[3]=1

    回溯

    a[3]=3,top=3

    ......

    ——方田

  • 0
    @ 2008-01-02 21:44:57

    看了最下一位大牛的题解~~~恍然大悟

  • 0
    @ 2007-12-28 17:14:58

    深搜怎么超时呢??

信息

ID
1092
难度
5
分类
组合数学 点击显示
标签
(无)
递交数
4510
已通过
1397
通过率
31%
被复制
11
上传者