結果
問題 | No.320 眠れない夜に |
ユーザー |
![]() |
提出日時 | 2015-12-17 15:36:33 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 564 bytes |
コンパイル時間 | 1,416 ms |
コンパイル使用メモリ | 161,360 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-16 07:31:59 |
合計ジャッジ時間 | 2,687 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 31 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long LL; LL f[100]; LL dp[100]; set<LL> x; void init(){ f[1]=1; f[2]=1; for(int i=3;i<=80;i++){ f[i]=f[i-1]+f[i-2]; //cout<<i<<" "<<f[i]<<endl; } } int main() { init(); LL N,M; cin>>N>>M; M=f[N]-M; if(M<0){ cout<<-1<<endl; return 0; } int cnt=0; for(int i=3;i<=N;i++){ if(f[N-i+1]<=M){ cnt++; M-=f[N-i+1]; } } if(M==0)cout<<cnt<<endl; else cout<<-1<<endl; return 0; }