125 条题解
-
0Star_Gym LV 3 @ 2006-10-26 08:44:07
O(n)也要150ms啊...
-
02006-10-17 12:56:40@
cutedog,
你难道不能说得明白些??? -
02006-08-08 21:55:25@
这个题O(N)的算法就可以了吧.
-
-12016-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.
-
-12016-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.