結果
問題 | No.320 眠れない夜に |
ユーザー |
|
提出日時 | 2020-03-02 20:13:28 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 316 bytes |
コンパイル時間 | 438 ms |
コンパイル使用メモリ | 63,744 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-13 21:16:35 |
合計ジャッジ時間 | 1,557 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 31 |
コンパイルメッセージ
main.cpp:5:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 5 | main() | ^~~~
ソースコード
#include<iostream>using namespace std;int N;long M,A[80];main(){cin>>N>>M;A[0]=A[1]=1;int ans=0;for(int i=2;i<N;i++){A[i]=A[i-1]+A[i-2];A[i]--;for(int k=i+1;k<N;k++){A[k]=A[k-1]+A[k-2];}if(A[N-1]>=M)ans++;else A[i]++;}if(A[N-1]==M)cout<<ans<<endl;else cout<<-1<<endl;}