fork download
  1. uses math;
  2.  
  3. var
  4. dp:array[0..101,0..101] of int64;
  5. a:array[0..101] of longint;
  6. sum:int64;
  7. n,m,i,j,k:longint;
  8. s:ansistring;
  9.  
  10. begin
  11.  
  12. assign(input,'input.txt'); reset(input);
  13. assign(output,'output.txt'); rewrite(output);
  14.  
  15. readln(n,m);
  16. for i:=1 to n do
  17. begin
  18. readln(s);
  19. for j:=1 to length(s) do
  20. if s[j] in['-','+',':','*'] then inc(a[i]);
  21. end;
  22.  
  23. dp[0][0]:=1;
  24.  
  25. for i:=1 to n do
  26. begin
  27. for j:=0 to i-1 do
  28. if(a[j]<a[i]) then
  29. for k:=1 to min(i,m) do
  30. dp[i][k]:=dp[i][k]+dp[j][k-1];
  31. end;
  32.  
  33. sum:=0;
  34. for i:=1 to n do
  35. sum:=sum+dp[i][m];
  36.  
  37. if sum = 0 then writeln(-1) else
  38.  
  39. writeln(sum);
  40.  
  41. end.
Runtime error #stdin #stdout 0s 516KB
stdin
Standard input is empty
stdout
An unhandled exception occurred at $08048115 :
EInOutError : File not found
  $08048115