比赛 20101119 评测结果 AATTTTTTTT
题目名称 求和 最终得分 20
用户昵称 magic 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2010-11-19 09:17:51
显示代码纯文本
program gls;
var

n,a,b,k,i,j,ans,sum:longint;
ss:array[1..1000000]of longint;
st:array[0..1000000]of int64;
f,g:text;
   function min(a,b:longint):longint;
   begin
     if a>b then exit(b) else exit(a);
   end;


begin
  assign(f,'suma.in');
  reset(f);
  assign(g,'suma.out');
  rewrite(g);
  readln(f,n,a,b);
  for k:=1 to n do
  readln(f,ss[k]);
  st[1]:=ss[1];
  st[0]:=0;
  for k:=2 to n do
     st[k]:=st[k-1]+ss[k];
 { for k:=1 to n do
  write(g,st[k],' ');
  writeln(g); }
     ans:=maxlongint;
    for i:=1 to n-1 do
      for j:=i to n do
    begin sum:=0;
        sum:=st[j]-st[i-1];
       if sum mod b>=a then
         ans:=min(ans,sum mod b);
    end;








 writeln(g,ans);
close(f);close(g);
end.