比赛 20110729 评测结果 AAATTTTTTT
题目名称 sumcount 最终得分 30
用户昵称 ybh 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2011-07-29 12:31:18
显示代码纯文本
program sumcount;
var
  f:array[0..1,0..1000000] of longint;
  n,a,b,p,i,j,ans,h:longint;
  
begin
  assign(input,'sumcount.in');
  reset(input);
  assign(output,'sumcount.out');
  rewrite(output);
  
  readln(n,a,b,p);
  f[0,0]:=1;
  h:=0;
  for i:=1 to n do
  begin
    h:=1-h;
    for j:=0 to b do
      f[h,j]:=(f[1-h,j]+f[h,j-1]) mod p;
  end;
  ans:=0;
  for i:=a to b do
    ans:=(ans+f[h,i]) mod p;
  writeln(ans);
  
  close(input);
  close(output);
end.