/ Vijos / 题库 / 数列 /

题解

149 条题解

  • 0
    @ 2012-10-26 22:18:17

    编译通过...

    ├ 测试数据 01:答案正确... (0ms, 580KB)

    ├ 测试数据 02:答案正确... (0ms, 580KB)

    ├ 测试数据 03:答案正确... (0ms, 580KB)

    ├ 测试数据 04:答案正确... (0ms, 580KB)

    ├ 测试数据 05:答案正确... (0ms, 580KB)

    ├ 测试数据 06:答案正确... (0ms, 580KB)

    ├ 测试数据 07:答案正确... (0ms, 580KB)

    ├ 测试数据 08:答案正确... (0ms, 580KB)

    ├ 测试数据 09:答案正确... (0ms, 580KB)

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

    Accepted / 100 / 0ms / 580KB

    农夫山泉有点甜

  • 0
    @ 2010-07-14 13:24:13

    再加上分治

    #include

    using namespace std;

    int k,n,len,tot,i;

    int f[100];

    bool is_known[100],bin[100];

    int calc(int n)

    {

    int i,j;

    if(is_known[n])return f[n];

    if(n%2==0)

    {

    f[n]=calc(n/2)*calc(n/2);

    is_known[n]=true;

    return f[n];

    }

    f[n]=calc(n/2)*calc(n/2)*k;

    is_known[n]=true;

    return f[n];

    }

    int main()

    {

    freopen("sequence.in","r",stdin);

    freopen("sequence.out","w",stdout);

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

    f[0]=1;is_known[0]=true;

    len=1;

    while(n!=1)

    {

    bin[len]=n%2;

    n=n/2;

    len++;

    }

    bin[len]=true;

    for(i=1;i

  • 0
    @ 2010-04-11 12:12:30

    终于AC100题啦!!!

  • 0
    @ 2009-11-10 15:37:19

    松松的过了

    program p1319;

    var

    n,i,k,ans:longint;

    begin

    readln(n,k);

    i:=1;

    while k0 do

    begin

    ans:=ans+1 and k*i;

    k:=k shr 1;

    i:=i*n;

    end;

    writeln(ans);

    end.

  • 0
    @ 2009-11-09 11:46:31

    ans:=0;a:=1;

    while n>0 do begin

    if n mod 2=1 then inc(ans,a);

    n:=n div 2;

    a:=a*k;

    end;

    writeln(ans);

    ac

  • 0
    @ 2009-11-09 11:41:10

    哥果断被这题封号三天。

    囧了 ……………………

  • 0
    @ 2009-11-05 21:18:28

    3^5 3^4 3^3 3^2 3^1 3^0

    n=1 1

    n=2 1 0

    n=3 1 1

    n=4 1 0 0

    n=5 1 0 1

    n=6 1 1 0

    n=7 1 1 1

    n=8 1 0 0 0

    n=9 1 0 0 1

    n=10 1 0 1 0

    ……

    以此类推

  • 0
    @ 2009-10-30 21:01:11

    编译通过...

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

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

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

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

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

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

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

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

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

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

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

    找规律,二进制,秒之

  • 0
    @ 2009-10-29 23:19:40

    编译通过...

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

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

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

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

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

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

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

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

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

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

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

    好久没有一次AC了....为什么06普及的题思想都差不多...

  • 0
    @ 2009-10-27 19:09:46

    我水...想不出二进制算法,只好花了10分钟想了另外一个算法...

    program voj1319;

    var

    ans:array[0..2000] of int64;

    n,k:longint;

    procedure init;

    begin

    readln(k,n);

    end;

    function calc(tt:longint):int64;

    var i:integer;

    begin

    calc:=1;

    for i:=1 to tt do

    calc:=calc*k;

    end;

    procedure work;

    var i,tot,tt,t:longint;

    temp:int64;

    begin

    ans[1]:=1;

    tot:=1;

    tt:=0;

    while true do

    begin

    if tot>n then

    begin

    writeln(ans[n]);

    halt;

    end;

    inc(tt);

    temp:=calc(tt);

    inc(tot);

    ans[tot]:=temp;

    t:=tot;

    for i:=1 to t-1 do

    begin

    inc(tot);

    ans[tot]:=temp+ans[i];

    end;

    end;

    end;

    begin

    init;

    work;

    end.

  • 0
    @ 2009-10-25 13:43:41

    编译通过...

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

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

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

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

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

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

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

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

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

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

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

    #include

    using namespace std;

    int main()

    {

    int a[1001],i,j,k,n,t=1;

    cin>>k>>n;

    a[1]=1;

    for (i=2;i

  • 0
    @ 2009-10-11 16:46:45

    编译通过...

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

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

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

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

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

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

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

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

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

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

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

    想了好久

  • 0
    @ 2009-10-07 21:22:15

    easy

  • 0
    @ 2009-10-07 17:43:51

    4分钟搞定。。

    贴上程序:

    var k,n,ans,t,x:longint;

    begin

    readln(k,n);

    t:=1;

    while n0 do

    begin

    x:=n and 1;

    inc(ans,t*x);

    t:=t*k;

    n:=n shr 1;

    end;

    writeln(ans);

    end.

  • 0
    @ 2009-10-02 11:23:18

    参看了大牛的二进制法 写了个很短的程序 但是原理还不是很清楚啊

    #include

    int n,k;

    double cf(int i)

    {

    double p=1;

    int j;

    for (j=1;j

    • @ 2015-10-24 11:38:17

      你的程序在洛谷上测试是90分,第九个点不对

  • 0
    @ 2009-09-26 17:14:57

    娃哈哈矿泉水.....

    我直接用int64 ,如果在noip考场上,自己应该会写个高精吧...

  • 0
    @ 2009-09-22 12:00:13

    var

    k,n,i,l,w,s:longint;

    j:real;

    procedure check;

    begin

    i:=1;

    l:=2;

    w:=0;

    while l

  • 0
    @ 2009-09-21 21:02:36

    鄙视出错的样例

    害我一直以为我是错的

    不敢提交

  • 0
    @ 2009-09-21 13:48:49

    非二进制解法

    var

    num:array[1..1000]of longint;

    cf:array[0..45]of longint;

    k,n,i:integer;

    function chengfang(x:longint;t:integer):longint;

    var

    i:integer;

    x2:longint;

    begin

    x2:=1;

    for i:=1 to t do

    begin

    if x2>(maxlongint div k) then exit(0);

    x2:=x2*x;

    end;

    exit(x2);

    end;

    procedure solve;

    var

    i,j:integer;

    times:integer;

    begin

    times:=1;

    for i:=2 to 45 do

    begin

    inc(times);

    num[times]:=cf;

    for j:=1 to times-1 do

    begin

    inc(times);

    num[times]:=num[j]+cf;

    if times=n then exit;

    end;

    end;

    end;

    begin

    read(k,n);

    for i:=0 to 45 do cf[i]:=chengfang(k,i);

    fillchar(num,sizeof(num),0);

    num[1]:=1;

    solve;

    write(num[n]);

    end.

  • 0
    @ 2009-09-17 20:39:05

    赞rizhao的题解

    话说我还真不知道该怎么做的……noip之前,把它背过吧……

信息

ID
1319
难度
1
分类
数论 | 其他 | 数学 点击显示
标签
递交数
2435
已通过
1607
通过率
66%
被复制
21
上传者