题解

125 条题解

  • 0
    @ 2006-10-26 08:44:07

    O(n)也要150ms啊...

  • 0
    @ 2006-10-17 12:56:40

    cutedog,

    你难道不能说得明白些???

  • 0
    @ 2006-08-08 21:55:25

    这个题O(N)的算法就可以了吧.

  • -1
    @ 2016-11-23 21:16:42
    var
        count:array[0..100000] of longint;
        i,n,k,temp,tot,temp2:longint;
    begin
        readln(n,k);    
        fillchar(count,sizeof(count),0);
        temp2:=0;count[0]:=1;
        for i:=1 to n do
            begin
                readln(temp);
                temp2:=(temp2+temp) mod k;
                inc(count[temp2]);
            end;
        tot:=0;
        for i:=0 to k-1 do
            if count[i]<>0 then
                    begin
                        inc(tot,(count[i]*(count[i]-1)) shr 1);
                        tot:=tot mod 1234567;
                    end;
       **writeln(tot);**
    end.
    
  • -1
    @ 2016-11-23 21:16:00
    var
        count:array[0..100000] of longint;
        i,n,k,temp,tot,temp2:longint;
    begin
        readln(n,k);    
        fillchar(count,sizeof(count),0);
        temp2:=0;count[0]:=1;
        for i:=1 to n do
            begin
                readln(temp);
                temp2:=(temp2+temp) mod k;
                inc(count[temp2]);
            end;
        tot:=0;
        for i:=0 to k-1 do
            if count[i]<>0 then
                    begin
                        inc(tot,(count[i]*(count[i]-1)) shr 1);
                        tot:=tot mod 1234567;
                    end;
        writeln(tot);
    end.
    

信息

ID
1090
难度
5
分类
其他 | 数学 点击显示
标签
(无)
递交数
3928
已通过
1252
通过率
32%
被复制
19
上传者