結果
問題 | No.320 眠れない夜に |
ユーザー |
![]() |
提出日時 | 2015-12-13 00:34:10 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 1 ms / 2,000 ms |
コード長 | 376 bytes |
コンパイル時間 | 261 ms |
コンパイル使用メモリ | 22,272 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-15 10:52:41 |
合計ジャッジ時間 | 1,251 ms |
ジャッジサーバーID (参考情報) |
judge6 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 31 |
コンパイルメッセージ
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("%lld%lld", &n, &m); | ~~~~~^~~~~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h>long long int n, m, f[81];int main(void) {scanf("%lld%lld", &n, &m);long long int i;f[1] = 1, f[2] = 1;for(i = 3; i <= n; i++) {f[i] = f[i - 1] + f[i - 2];}long long int r = f[n] - m, counter = 0;for(i = n - 2; 1 <= i; i--) {if(f[i] <= r) { r -= f[i]; counter++; }}printf("%lld\n", (r == 0 ? counter : -1) );return 0;}