結果
問題 | No.612 Move on grid |
ユーザー |
|
提出日時 | 2017-12-13 22:27:17 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 107 ms / 2,500 ms |
コード長 | 582 bytes |
コンパイル時間 | 1,605 ms |
コンパイル使用メモリ | 158,980 KB |
実行使用メモリ | 46,720 KB |
最終ジャッジ日時 | 2024-12-18 00:54:30 |
合計ジャッジ時間 | 3,682 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 17 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:17:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 17 | scanf("%d",&T); | ~~~~~^~~~~~~~~ main.cpp:18:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 18 | scanf("%d%d%d%d%d",&a,&b,&c,&d,&e); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h>using namespace std;const int MOD = 1e9+7;int f[510][22000];int T,a,b,c,d,e;void upd(int &x,int y){x += y;if (x >= MOD) x -= MOD;}int main(){scanf("%d",&T);scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);f[0][10100] = 1;for (int i=0;i<T;i++){for (int j=20;j<=20980;j++){upd(f[i+1][j+a],f[i][j]);upd(f[i+1][j+b],f[i][j]);upd(f[i+1][j+c],f[i][j]);upd(f[i+1][j-a],f[i][j]);upd(f[i+1][j-b],f[i][j]);upd(f[i+1][j-c],f[i][j]);}}int ans = 0;for (int i=d;i<=e;i++)upd(ans,f[T][i+10100]);printf("%d\n",ans);}