結果
問題 |
No.657 テトラナッチ数列 Easy
|
ユーザー |
|
提出日時 | 2018-04-10 19:13:54 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
RE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 526 bytes |
コンパイル時間 | 142 ms |
コンパイル使用メモリ | 24,960 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-26 20:55:52 |
合計ジャッジ時間 | 1,030 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 RE * 1 |
other | AC * 13 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:6:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 6 | scanf("%d", &Q); | ~~~~~^~~~~~~~~~ main.cpp:12:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 12 | scanf("%d", &n); | ~~~~~^~~~~~~~~~
ソースコード
#include<cstdio> #include<cstdlib> int main(void) { int i, j, a[5], Q, n, Max; scanf("%d", &Q); int *b = (int *)calloc(Q, sizeof(int)); Max = 0; for (j = 0; j < Q; j++) { scanf("%d", &n); b[j] = n; if (b[j] > Max) { Max = b[j]; } } int *c = (int *)calloc(Max, sizeof(int)); c[0] = 0; c[1] = 0; c[2] = 0; c[3] = 1; for (i = 0; i < Max - 3; i++) { c[i + 4] = (c[i+3] + c[i+2] + c[i+1] + c[i]) % 17; } for (j = 0; j < Q; j++) { printf("%d", c[b[j]-1]); printf("\n"); } return 0; }