結果
| 問題 |
No.612 Move on grid
|
| コンテスト | |
| ユーザー |
ikd
|
| 提出日時 | 2017-12-14 12:24:23 |
| 言語 | D (dmd 2.109.1) |
| 結果 |
AC
|
| 実行時間 | 123 ms / 2,500 ms |
| コード長 | 851 bytes |
| コンパイル時間 | 1,002 ms |
| コンパイル使用メモリ | 99,844 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-06-12 23:04:22 |
| 合計ジャッジ時間 | 2,368 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 17 |
ソースコード
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;
}
ikd