题解

144 条题解

  • 0
    @ 2008-11-11 08:18:40

    = = ……话说那DIV 和MOD 搞得我好晕……晕着晕着就写完了,晕着晕着就交了,然后就AC了= =。。。

  • 0
    @ 2008-11-10 22:41:50

    好难啊,什么康托展开,先睡觉了

  • 0
    @ 2008-11-06 11:18:55

    去北京的火车上,半夜某崔研究的一道题,还是在某本数学竞赛书上……好麻烦的说

  • 0
    @ 2008-11-04 23:02:59

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

    康托。

    最后一位似乎要单独处理。每次排除用过的选剩下中第几大的。

    整整写了1.5小时= =~

  • 0
    @ 2008-11-02 20:00:45

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

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

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

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

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

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

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

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

    不要贪心,不要搜索,直接用数学方法ac.

    program p1092;

    var

    n,m:int64;

    i,j,t:integer;

    jc:array[0..20] of int64;

    num:array[0..20] of integer;

    first:boolean;

    begin

    first:=true;

    readln(n,m);

    for i:=0 to n-1 do

    num[i]:=i+1;

    jc[0]:=1;

    jc[1]:=1;

    for i:=2 to n-1 do

    jc[i]:=jc*i;

    for i:=1 to n do

    begin

    t:=(m-1) div jc[n-i];

    if first then

    begin

    first:=false;

    write(num[t]);

    end

    else

    write(' ',num[t]);

    for j:=t to n-i do

    num[j]:=num[j+1];

    m:=((m-1) mod jc[n-i])+1;

    end;

    writeln;

    end.

  • 0
    @ 2008-11-02 13:34:26

    编译通过...

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

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

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

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

    ├ 测试数据 05:运行超时...

    ├ 测试数据 06:运行超时...

    ├ 测试数据 07:运行超时...

    ├ 测试数据 08:运行超时...

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

    Unaccepted 有效得分:50 有效耗时:431ms

    直接深搜超时的一塌糊涂。

    #include

    using namespace std;

    int arr[20],used[20],n,y,m;

    void dfs(int x);

    void out();

    int main()

    {

    cin>>n>>m;

    dfs(1);

    return 0;

    }

    void out()

    {

    for(int i=1;i

  • 0
    @ 2008-10-31 22:00:07

    编译通过...

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

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

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

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

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

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

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

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

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

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

    利用组合计数理论直接贪心(大牛们把这叫康托展开什么的)

    对从低往高数第i位,取除前(n-i)个数外第(m div (i-1)!)+1 小的,然后将m变为m-(m div (i-1)!)*(i-1)!,再递推从低到高第i-1位...

    预处理为计算n!

    主过程平均时间复杂度为大欧(1+2+3+...+n-1);

    代码稍长,80行,带高精减与高精比较

    program p1092;

    var

    a:array [1..19,0..50] of integer;

    n,i,j,k,l:longint;

    m,re:array [0..50] of integer;

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

    s:string;

    function max(i1:integer):integer;

    begin

    if m[0]>a[i1,0] then exit(1);

    if m[0]0) do dec(j);

    if j=0 then exit(0);

    if m[j]>a[i1,j] then exit(1);

    if m[j]1 do begin

    i:=1;

    while whe[i]=false do inc(i);

    while max(k-1)=1 do begin

    mt;

    inc(i);

    while whe[i]=false do inc(i);

    end;

    re[n-k+1]:=i;

    whe[i]:=false;

    dec(k);

    end;

    i:=1;

    while whe[i]=false do inc(i);

    re[n]:=i;

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

    writeln(re[n]);

    end.

  • 0
    @ 2008-10-31 20:27:27

    写的比较弱智。。。

    program p1092;

    var

    n ,m ,left :int64;

    i ,j ,k ,s ,temp:longint;

    a :Array[0..20] of int64;

    mark :Array[0..20] of boolean;

    function jc(x:longint):int64;

    var

    i :longint;

    begin

    jc:=1;

    for i:=2 to x do

    jc:=jc*i;

    end;

    begin

    readln(n,m);

    left:=m;

    for i:=0 to 20 do

    a[i]:=jc(i);

    for i:=n downto 1 do

    begin

    k:=1;

    for j:=0 to n do

    if a*j

  • 0
    @ 2008-10-29 19:09:22

    继续注册前请先阅读 Vijos 网站协议

      Vijos 为 Velocious Informatics Judge Online System 高效信息学在线评测系统,为广大信息学爱好者构建了网络学习平台。注册用户都拥有站点浏览、学习、交流、讨论等权利。

      为维护网上公共秩序和社会稳定,请您自觉遵守以下条款:

      一、不得利用本站危害国家安全、泄露国家秘密,不得侵犯国家社会集体的和公民的合法权益,不得利用本站制作、复制和传播下列信息:

      (一)煽动抗拒、破坏宪法和法律、行政法规实施的;

      (二)煽动颠覆国家政权,推翻社会主义制度的;

      (三)煽动分裂国家、破坏国家统一的;

      (四)煽动民族仇恨、民族歧视,破坏民族团结的;

      (五)捏造或者歪曲事实,散布谣言,扰乱社会秩序的;

      (六)宣扬封建迷信、淫秽、色情、赌博、暴力、凶杀、恐怖、教唆犯罪的;

      (七)公然侮辱他人或者捏造事实诽谤他人的,或者进行其他恶意攻击的;

      (八)损害国家机关信誉的;

      (九)其他违反宪法和法律行政法规的;

      (十)进行商业广告行为的。

      二、互相尊重,对自己的言论和行为负责。

  • 0
    @ 2008-10-29 19:07:06
  • 0
    @ 2008-10-29 11:17:22

    编译通过...

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

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

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

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

    ├ 测试数据 05:运行超时...

    ├ 测试数据 06:运行超时...

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

    ├ 测试数据 08:运行超时...

    …………运行超时~~~~(>_

  • 0
    @ 2008-10-23 19:26:15

    program v1092;

    var a:array[1..20]of longint;

    i,j:longint;

    bb,n,k:int64;

    m:qword;

    begin

    readln(n,m);

    bb:=1;

    for i:=2 to n-1 do bb:=bb*i;

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

    i:=1;

    if m=1 then begin

    for j:=1 to n do write(a[j],' ');

    exit;

    end;

    while i0 do begin

    m:=m-bb;inc(k);

    end;

    write(a[k],' ');

    for j:=k to n-1 do a[j]:=a[j+1];

    bb:=bb div (n-i);

    inc(i);

    end;

    end.

    编译通过...

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

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

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

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

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

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

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

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

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

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

  • 0
    @ 2008-10-17 21:21:51

    var

    n,i,j:longint;

    us:Array[1..20] of boolean;

    m:int64;

    s,st:string;

    function jc(x:longint):int64;//阶乘

    begin

    jc:=1;

    while x>0 do

    begin

    jc:=jc*x;

    dec(x);

    end;

    end;

    begin

    readln(n,m);

    for i:=1 to n do

    begin

    j:=1;

    while us[j] do inc(j);

    while m-jc(n-i)>0 do

    begin inc(j);while us[j] do inc(j); m:=m-jc(n-i); end;

    str(j,st);

    s:=s+' '+st;

    us[j]:=true;

    end;

    delete(s,1,1);

    writeln(s);

    end.

  • 0
    @ 2008-10-17 15:26:35

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

    ├ 测试数据 02:答案错误... ├ 标准行输出

     ├ 错误行输出

    ├ 测试数据 03:答案错误... ├ 标准行输出

     ├ 错误行输出

    ├ 测试数据 04:答案错误... ├ 标准行输出

     ├ 错误行输出

    ├ 测试数据 05:运行超时...

    ├ 测试数据 06:运行超时...

    ├ 测试数据 07:答案错误... ├ 标准行输出

     ├ 错误行输出

    ├ 测试数据 08:运行超时...

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

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

  • 0
    @ 2008-10-14 16:34:21

    编译通过...

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

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

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

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

    ├ 测试数据 05:答案错误... ├ 标准行输出

     ├ 错误行输出

    ├ 测试数据 06:答案错误... ├ 标准行输出

     ├ 错误行输出

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

    ├ 测试数据 08:答案错误... ├ 标准行输出

     ├ 错误行输出

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

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

  • 0
    @ 2008-10-12 19:14:03

    编译通过...

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

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

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

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

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

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

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

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

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

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

    逆康托一次AC。读入M后记得减去个1。。

  • 0
    @ 2008-10-09 18:31:28

    编译通过...├ 测试数据 01:答案正确... 0ms├ 测试数据 02:答案正确... 0ms├ 测试数据 03:答案正确... 0ms├ 测试数据 04:答案正确... 0ms├ 测试数据 05:答案正确... 0ms├ 测试数据 06:答案正确... 0ms├ 测试数据 07:答案正确... 0ms├ 测试数据 08:答案正确... 0ms-------------------------Accepted 有效得分:100 有效耗时:0ms一个序列的康托展开是一个整数,这个整数就是题目中给的M。这道题就是已知康托展开数求这个序列!

  • 0
    @ 2008-10-07 23:18:49

    编译通过...

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

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

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

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

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

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

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

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

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

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

    数学题目

    我是先把m:=m-1,然后每一位从头到尾枚举,如果符合就记录,再把m减去相应的值

  • 0
    @ 2008-09-30 08:07:48

    var

    k,i,l,n,m,s,j:longint;

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

    b:array[1..100]of longint;

    begin

    readln(n,k);

    a[0]:=1;

    for i:=1 to n do

    begin

    a[i]:=1;

    b[i]:=i;

    for j:=1 to i do

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

    end;

    l:=k-1;

    for i:=n-1 downto 1 do

    begin

    s:=l div a[i]+1;

    l:=l mod a[i];

    write(b,' ');

    for j:=s to n-1 do

    b[j]:=b[j+1];

    end;

    write(b[1],' ');

    end.

  • 0
    @ 2008-09-29 16:24:27

    n^2列举每一个数

    由于20!大约是10^19这样的级别,

    所以用qword就可以了

信息

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