結果
| 問題 |
No.320 眠れない夜に
|
| コンテスト | |
| ユーザー |
piyoko_212
|
| 提出日時 | 2015-12-21 18:33:23 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 2,000 ms |
| コード長 | 393 bytes |
| コンパイル時間 | 399 ms |
| コンパイル使用メモリ | 34,124 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-18 18:03:49 |
| 合計ジャッジ時間 | 1,384 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 31 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:8:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
8 | scanf("%d%lld",&a,&b);
| ~~~~~^~~~~~~~~~~~~~~~
ソースコード
#include<stdio.h>
#include<algorithm>
using namespace std;
long long f[100];
int main(){
int a;
long long b;
scanf("%d%lld",&a,&b);
f[1]=f[2]=1;
for(int i=3;i<=a;i++)f[i]=f[i-1]+f[i-2];
long long c=f[a]-b;
if(c<0){
printf("-1\n");return 0;
}
int cnt=0;
for(int i=a-2;i>=1;i--){
if(c>=f[i]){
c-=f[i];cnt++;
}
}
if(c!=0){
printf("-1\n");return 0;
}
printf("%d\n",cnt);
}
piyoko_212