比赛 20100913 评测结果 AAAAAAAAAA
题目名称 连续素数和 最终得分 100
用户昵称 reamb 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2010-09-13 19:59:06
显示代码纯文本
program lianxusushuhe;
var
  i,j,t,n:longint;
  a,s:array[0..10000]of longint;
  f:array[0..1500]of longint;
  biaozhi:boolean;
begin
  assign (input,'conprime.in');
  reset (input);
  assign (output,'conprime.out');
  rewrite (output);
    for i:=2 to 10000 do
    begin
      biaozhi:=true;
      for j:=2 to trunc(sqrt(i)) do
        if i mod j =0 then
        begin
          biaozhi:=false;
          break
        end;
      if biaozhi then
      begin
        t:=t+1;
        a[t]:=i
      end
    end;
    f[1]:=a[1];
    for i:=2 to t do
      f[i]:=f[i-1]+a[i];
    for i:=1 to t do
      for j:=i to t do
        if f[j]-f[i-1]<=10000 then
          s[f[j]-f[i-1]]:=s[f[j]-f[i-1]]+1;
    repeat
      readln (n);
      if n<>0 then
        writeln (s[n])
    until n=0;
  close (input);
  close (output)
end.