結果
問題 |
No.320 眠れない夜に
|
ユーザー |
![]() |
提出日時 | 2018-03-03 14:34:55 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 938 bytes |
コンパイル時間 | 723 ms |
コンパイル使用メモリ | 79,580 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-24 09:41:43 |
合計ジャッジ時間 | 1,870 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 31 |
ソースコード
#include<stdio.h> #include<string.h> #include<stdlib.h> #include<math.h> #include<stack> #include<queue> #include<vector> #include<algorithm> #include<string> #include<iostream> #include<set> #include<map> #include<bitset> using namespace std; typedef long long ll; #define i_7 1000000007 #define i_5 1000000005 ll mod(ll a){ ll c=a%i_7; if(c>=0)return c; else return c+i_7; } typedef pair<int,int> i_i; typedef pair<ll,ll> l_l; #define inf 100000000/*10^8*/ #define rep(i,l,r) for(int i=l;i<=r;i++) const double EPS=1E-8; //////////////////////////////////////// int main(){ ll n,m;cin>>n>>m; ll dp[81];dp[1]=1;dp[2]=1;rep(i,3,80)dp[i]=dp[i-1]+dp[i-2]; ll sum=dp[n]-m; int ans=0,pos=n-2; while(sum>0&&pos>=1){ if(dp[pos]<=sum){ sum-=dp[pos]; ans++; } pos--; } if(sum!=0){ cout<<-1;return 0; } cout<<ans<<endl; return 0; }