結果

問題 No.612 Move on grid
ユーザー ikdikd
提出日時 2017-12-14 12:24:23
言語 D
(dmd 2.107.1)
結果
AC  
実行時間 124 ms / 2,500 ms
コード長 851 bytes
コンパイル時間 810 ms
コンパイル使用メモリ 84,592 KB
実行使用メモリ 6,712 KB
最終ジャッジ日時 2023-09-03 17:33:24
合計ジャッジ時間 2,729 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,508 KB
testcase_03 AC 10 ms
6,684 KB
testcase_04 AC 27 ms
6,712 KB
testcase_05 AC 124 ms
6,680 KB
testcase_06 AC 121 ms
6,668 KB
testcase_07 AC 23 ms
6,676 KB
testcase_08 AC 120 ms
6,700 KB
testcase_09 AC 64 ms
6,672 KB
testcase_10 AC 46 ms
6,704 KB
testcase_11 AC 16 ms
6,680 KB
testcase_12 AC 71 ms
6,652 KB
testcase_13 AC 27 ms
6,680 KB
testcase_14 AC 95 ms
6,712 KB
testcase_15 AC 17 ms
6,712 KB
testcase_16 AC 107 ms
6,676 KB
testcase_17 AC 19 ms
6,704 KB
testcase_18 AC 89 ms
6,668 KB
testcase_19 AC 33 ms
6,708 KB
testcase_20 AC 47 ms
6,712 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

void main(){
  import std.stdio, std.string, std.conv, std.algorithm;

  int t; rd(t);
  int a, b, c, d, e; rd(a, b, c, d, e);

  auto dir=[a, -a, b, -b, c, -c];
  const mod=1_000_000_000+7;

  auto rec=new int[](30000);
  auto ofse=rec.length/2;
  rec[0+ofse]=1;
  for(auto i=1; i<=t; i++){
    auto tmp=new int[](rec.length);
    for(auto j=0; j<30000; j++)if(rec[j]>0){
      foreach(k; dir) 
        assert(0<=j+k && j+k<30000), (tmp[j+k]+=rec[j])%=mod;
    }
    swap(rec, tmp);
  }

  int tot=0;
  for(auto j=d+ofse; j<=e+ofse; j++) (tot+=rec[j])%=mod;
  writeln(tot);
}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}
void wr(T...)(T x){
  import std.stdio;
  foreach(e; x) stderr.write(e, " ");
  stderr.writeln;
}
0