- 连续数之和
- 2008-12-21 14:49:35 @
program xaq;
var
n,k,i,o:longint;
sum,b:array[0..500000]of int64;
mx:int64;
begin
read(n,k);
for i:=1 to n do
begin
read(o);
sum[i]:=sum+o;
inc(b[sum[i]mod k]);
end;
for i:=0 to k-1 do
mx:=mx+(b[i]*b[i]-1)shr 1;
write(mx mod 1234567);
end.
我是按照一位大牛的思路写的,为什么错了?
1 条评论
-
wu zhuo LV 10 @ 2009-07-16 09:13:47
b[0]:=1;
注意:1~i的和为sum[i]-sum[0]
- 1