比赛 暑假培训一 评测结果 AAAAA
题目名称 选数 最终得分 50
用户昵称 Hamster 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2008-07-17 11:11:15
显示代码纯文本
program choose (fin,fout);
  var
    fin,fout:text;
    n,k:integer;
    a,b:array [1..20] of longint;
    i,j,swap:integer;
    s,p:longint;
    sum:longint;
  procedure jurde (t:longint);
    var
      i:longint;
    begin
      for i:=2 to trunc(sqrt(t)) do
        if (t mod i=0) then exit;
      sum:=sum+1;
    end;

  procedure chose(f,t:integer);
    var
      i:integer;
    begin
      for i:=t to n do
        begin
          s:=s+a[i];
          if (f=k) then begin p:=p+1; jurde(s);end;
          if (f<k) then chose (f+1,i+1);
          s:=s-a[i];
        end;{for}
    end;


  begin
    assign (fin,'choose.in');
    reset (fin);
    assign (fout,'choose.out');
    rewrite (Fout);
    p:=0;
    readln (fin,n,k);
    for i:=1 to n do
      read (fin,a[i]);

    {Being in order}
    for i:=1 to n-1 do
      for j:=i+1 to n do
        if a[i]<a[j]
           then begin
           swap:=a[i];
           a[i]:=a[j];
           a[j]:=swap;
           end;

    sum:=0;
    chose(1,1);

    write (fout,sum);
    close (fin);
    close (fout);
  end.