记录编号 258 评测结果 AAAAA
题目名称 [NOIP 2002]选数 最终得分 100
用户昵称 Gravatar辨机ZN 是否通过 通过
代码语言 Pascal 运行时间 0.035 s
提交时间 2008-07-18 08:25:49 内存使用 0.12 MiB
显示代码纯文本
program ex(f1,f2);
 type
  zs=array [1..1230] of integer;
  zn=array [1..2000] of longint;
  na=array [1..21] of longint;
 var
  ss:zs; a,b:na; f1,f2:text;
  i,j,k,m,n:integer; total:longint; answer:longint;
 procedure sushubiao;
  var i,j,q,m:integer; flag:boolean;
 begin
  q:=2;
  for i:=5 to 10000 do
   begin
    flag:=true;
    for j:=2 to trunc(sqrt(i)) do
    if i mod j=0 then
     begin
      flag:=false;
      break;
     end;
    if flag then
     begin
      inc(q);
      ss[q]:=i;
     end;
   end;
  end;
procedure panduan(shu:integer);
 var v:integer; flag2:boolean;
 begin
  v:=1; flag2:=true;
  while (trunc(sqrt(shu))>=ss[v]) and (flag2) do
   begin
    if shu mod ss[v]=0 then flag2:=false;
    inc(v);
   end;
  if flag2=true then inc(answer);
 end;
procedure pailie(p,step:integer);
 var i:integer;
  begin
  for i:=p to n do
   begin
    b[step]:=a[i];
    if step=k then
                begin
                 total:=0;
                 for j:=1 to k do total:=total+b[j];
                 panduan(total);
                end
               else
               pailie(i+1,step+1);
   end;
  end;
 begin
  assign(f1,'choose.in'); reset(f1);
  assign(f2,'choose.out'); rewrite(f2);
  readln(f1,n,k);
  for i:=1 to n do read(f1,a[i]);
  ss[1]:=2; ss[2]:=3;
  answer:=0;
  sushubiao;
  for i:=1 to n do b[i]:=0;
  pailie(1,1);
  writeln(f2,answer);
  close(f1);
  close(f2);
 end.