240 条题解

  • 0
    @ 2009-08-03 13:28:48

    晕,没看到mod 7654321,高精都用上了,WA3次

    编译通过...

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

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

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

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

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

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

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

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

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

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

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

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

    var s:array[1..2] of int64;

    n,a:longint;

    begin

    read(n);

    if n

  • 0
    @ 2009-08-03 10:52:11

    +_+,我开始没看清题目。

  • 0
    @ 2009-08-03 10:37:07

    var n,i:longint;

    ab:array [0..10001] of longint;

    begin

    ab[1]:=1;

    ab[2]:=1;

    readln(n);

    if n

  • 0
    @ 2009-08-02 19:23:40

    菲波列契数列

  • 0
    @ 2009-07-30 21:37:01

    4495!!!

    笨方法:

    for i:=2 to n do begin

    f[y,1]:=f[x,3] mod maxn;

    f[y,2]:=f[x,4] mod maxn;

    f[y,3]:=f[x,1]+f[x,4] mod maxn;

    f[y,4]:=f[x,2]+f[x,3] mod maxn;

    x:=3-x;

    y:=3-y;

    end;

    最后把F[X,I]累加起来输出就可以了。。。。

    水。。。。。。。。

  • 0
    @ 2009-07-29 13:48:09

    #include

    #include

    #include

    #include

    #include

    typedef long long int64;

    int i,j,k;

    int temp;

    int ans;

    int64 a[100001];

    int n;

    int main (void)

    {

    // freopen("p1093.in","r",stdin);

    // freopen("p1093.out","w",stdout);

    scanf("%d",&n);

    a[0]=0;

    a[1]=1;

    for(i=2;i

  • 0
    @ 2009-07-29 12:59:39

    var a,b,c,n,i:longint;

    begin

    readln(n);

    a:=1;b:=1;

    if n=1 then writeln('1');

    if n=2 then writeln('2');

    if (n1)and(n2) then

    begin

    for i:=3 to n do

    begin

    c:=(a+b) mod 7654321;

    a:=b;

    b:=c;

    end;

    writeln(c);

    end;

    end.

    靠,没考虑n=1和n=2……

  • 0
    @ 2009-07-29 09:20:47

    斐波那契数列~~其实连开数组都不用,用a,b,c滚动就好了。

    大牛的题目就是有那种乍一看很难实际很简单的特点~~

  • 0
    @ 2009-07-26 19:26:21

    饿,第4444个过的!汗!!

  • 0
    @ 2009-07-26 13:53:30

    var n,i:longint;

    a:array[1..10000]of longint;

    begin

    readln(n);

    a[1]:=1;

    a[2]:=1;

    if n3 then begin for i:=3 to n do a[i]:=(a+a)mod 7654321;writeln(a[n]);end;

    end.

    为什么这个会超时啊?

  • 0
    @ 2009-07-22 18:47:42

    编译通过...

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

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

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

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

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

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

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

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

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

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

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

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

    program p1093(input,output);

    var n,i:longint;

    ab:array [0..10001] of longint;

    begin

    ab[1]:=1;

    ab[2]:=1;

    readln(n);

    if n

  • 0
    @ 2009-07-20 08:22:19

    var

    f:array[1..10000,1..4]of longint;

    n,i:longint;

    function find(t,x:longint):longint;

    begin

    if t=1 then begin f[t,x]:=1;exit(1);end;

    if f[t,x]0 then exit(f[t,x]);

    case x of

    1:begin f[t,1]:=find(t-1,3); f[t,1]:=f[t,1] mod 7654321; exit(f[t,1]);end;

    2:begin f[t,2]:=find(t-1,4); f[t,2]:=f[t,2] mod 7654321; exit(f[t,2]);end;

    3:begin f[t,3]:=find(t-1,1)+find(t-1,4);f[t,3]:=f[t,3] mod 7654321;exit(f[t,3]);end;

    4:begin f[t,4]:=find(t-1,2)+find(t-1,3);f[t,4]:=f[t,4] mod 7654321;exit(f[t,4]);end;

    end;

    end;

    begin

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

    read(n);

    write(find(n,1) mod 7654321);

    end.

    水体也用记忆化.....

  • 0
    @ 2009-07-18 13:46:39

    如果考试总数是1或者2,那么考试方法是1种,否则就是前两次的方法总数之和

  • 0
    @ 2009-07-17 15:34:52

    program das;

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

    n,i:integer;

    begin

    read(n);

    a[1]:=1;a[2]:=1;

    for i:=3 to n do a[i]:=(a+a) mod 7654321;

    write(a[n]);

    end.

    农夫山泉

    这代码不是人敲的

  • 0
    @ 2009-07-16 10:24:08

    Program yinshang;

    Var

    n,i:longint;

    a,b,c:qword;

    begin

    readln(n);

    a:=1;

    b:=1;

    for i:= 3 to n do

    begin

    c:=a+b;

    a:=b;

    b:=c;

    b:=b Mod 7654321;

    end;

    writeln(b);

    readln

    end.

  • 0
    @ 2009-07-14 13:58:00

    program p1093;

    var a,b,c:qword;

    n,i:integer;

    begin

    read(n);

    a:=1; b:=1;

    for i:=3 to n do

    begin c:=a+b; a:=b; b:=c; b:=b mod 7654321; end;

    write(b);

    end.

  • 0
    @ 2009-07-10 11:10:54

    Matrix67 根据经典问题改编...

    好经典~

  • 0
    @ 2009-06-30 19:27:14

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

    n,i:longint;

    begin

    read(n);

    a[1]:=1;

    a[2]:=1;

    for i:=3 to n do

    a[i]:=(a+a) mod 7654321;

    writeln(a[n]);

    end.

  • 0
    @ 2009-06-30 15:05:50

    注意ans的初值要:=1; 前两个极端数据,答案是1,我输出的是0,两次才ac...

    这个题两个方法:1. 列几个猜想一下,发现是小菲,再证明一下,发现真的是小菲。(证明:把四门课分成两类,一类是后面只有一科的(叫单),一类是后面有两种可能科目的(叫双),那么政、综是第一类,史、地是第二类,那么第n科的方法数就是第n-1科中的单的数+双的数*2,又单的数+双的数=f[n-1],则f[n]=f[n-1] + f[n-1]中双的数目,又所有的四科都能且只能推出来一门双的科,那么f[n-1]中双的数目就是是f[n-2],有f[n]=f[n-1]+f[n-2],总算写完了。。。)然后就出来了

    2.相当于模拟。 dfs是过不去的,记忆化搜索的效果是很好的。虽然只多了个 if f0 then 但优化的结果是AC,是个不错的方法。

    写的不好,不过想了很久,参考一下就可以了。

  • 0
    @ 2009-06-27 23:29:23

    #include

    #include

    using namespace std;

    const int M = 7654321;

    int n, dp[4][10001];

    int go(int day, int p)

    {

    int & cnt = dp[p][day];

    if (cnt != -1) return cnt;

    if (day == n) return cnt = 1;

    if (p == 0) cnt = go(day + 1, 1);

    if (p == 3) cnt = go(day + 1, 2);

    if (p == 1) cnt = go(day + 1, 0) + go(day + 1, 2);

    if (p == 2) cnt = go(day + 1, 1) + go(day + 1, 3);

    cnt %= M;

    return cnt;

    }

    int main()

    {

    cin >> n;

    memset(dp, -1, sizeof(dp));

    cout

信息

ID
1093
难度
4
分类
模拟 点击显示
标签
(无)
递交数
6521
已通过
2835
通过率
43%
被复制
13
上传者