比赛 20100913 评测结果 AAAAAAWATA
题目名称 连续素数和 最终得分 80
用户昵称 maxiem 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2010-09-13 20:15:48
显示代码纯文本
program conprime;
var
  p:array [1..1300] of integer;
  n,total,ans,i,j,s:integer;
procedure get;
var
  flag:array [1..10000] of boolean;
  i,j,t:integer;
begin
  fillchar (flag,sizeof(flag),0);
  for i:=2 to 100 do begin
    t:=i*i;
    repeat
	  flag[t]:=true;
	  t:=t+i;
    until t>10000;
  end;
  total:=1;i:=3;
  p[total]:=2;
  repeat
    if not(flag[i]) then begin
	  inc(total);
	  p[total]:=i;
	end;
	inc(i,2);
  until i>10000;
end;
begin
  assign (input,'conprime.in');
  reset (input);
  assign (output,'conprime.out');
  rewrite (output);
  readln (n);
  get;
  while n<>0 do begin
    ans:=0;s:=0;
    for i:=1 to total do begin
      s:=p[i];
      if s>n then break;
	  for j:=i+1 to total do begin
	    if s=n then begin
		  inc(ans);
		  break;
		end
		else if s>n then break;
		s:=s+p[j];
	  end;
	end;
          writeln (ans);
	readln (n);
  end;
  close (input);
  close (output);
end.