結果
問題 |
No.44 DPなすごろく
|
ユーザー |
![]() |
提出日時 | 2016-12-22 00:38:59 |
言語 | C90 (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 1 ms / 5,000 ms |
コード長 | 324 bytes |
コンパイル時間 | 214 ms |
コンパイル使用メモリ | 20,992 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-12-14 14:11:40 |
合計ジャッジ時間 | 1,192 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 20 |
コンパイルメッセージ
main.c: In function ‘main’: main.c:15:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 15 | scanf("%d", &n); | ^~~~~~~~~~~~~~~
ソースコード
#include <stdio.h> #include <string.h> long long dp[51]; long long search(int i) { if (i == 0) return 1; if (i < 0) return 0; if (dp[i] != -1) return dp[i]; return dp[i] = search(i - 1) + search(i - 2); } int main() { int n; scanf("%d", &n); memset(dp, -1, sizeof(dp)); printf("%lld\n", search(n)); return 0; }