結果

問題 No.320 眠れない夜に
ユーザー mugen_1337mugen_1337
提出日時 2021-02-18 21:05:33
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,376 bytes
コンパイル時間 2,333 ms
コンパイル使用メモリ 199,844 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-10-13 04:35:12
合計ジャッジ時間 4,770 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 1 ms
4,368 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 2 ms
4,368 KB
testcase_16 AC 1 ms
4,368 KB
testcase_17 AC 1 ms
4,368 KB
testcase_18 AC 1 ms
4,368 KB
testcase_19 AC 2 ms
4,368 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 1 ms
4,372 KB
testcase_23 WA -
testcase_24 AC 1 ms
4,368 KB
testcase_25 AC 1 ms
4,372 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 2 ms
4,372 KB
testcase_29 AC 2 ms
4,368 KB
testcase_30 AC 1 ms
4,368 KB
testcase_31 AC 2 ms
4,368 KB
testcase_32 AC 2 ms
4,368 KB
testcase_33 WA -
testcase_34 AC 2 ms
4,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define ALL(x) begin(x),end(x)
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define mod 998244353
using ll=long long;
const int INF=1000000000;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

struct IOSetup{
    IOSetup(){
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(12);
    }
} iosetup;
 
template<typename T>
ostream &operator<<(ostream &os,const vector<T>&v){
    for(int i=0;i<(int)v.size();i++) os<<v[i]<<(i+1==(int)v.size()?"":" ");
    return os;
}
template<typename T>
istream &operator>>(istream &is,vector<T>&v){
    for(T &x:v)is>>x;
    return is;
}

// Zeckendorf's Theoram

signed main(){

    const int k=10;
    vector<ll> f(k+1);
    f[1]=1,f[2]=1;
    for(int i=3;i<=k;i++) f[i]=f[i-1]+f[i-2];

    ll n,m;cin>>n>>m;
    ll dif=f[n]-m;
    if(dif<0){
        cout<<-1<<endl;
        return 0;
    }
    int res=0;
    for(int i=n-2;i>0;i--){
        if(f[i]<=dif){
            dif-=f[i],res++;
        }
    }
    if(dif){
        cout<<-1<<endl;
    }else{
        cout<<res<<endl;
    }

    return 0;
}
0