結果

問題 No.320 眠れない夜に
ユーザー syoken_desuka
提出日時 2015-12-18 23:31:07
言語 C++11
(gcc 4.8.5)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 2,196 Byte
コンパイル時間 917 ms
使用メモリ 1,560 KB
最終ジャッジ日時 2020-05-15 01:44:26

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 2 ms
1,560 KB
testcase_01 AC 2 ms
1,560 KB
testcase_02 AC 2 ms
1,560 KB
testcase_03 AC 2 ms
1,556 KB
testcase_04 AC 2 ms
1,556 KB
testcase_05 AC 2 ms
1,556 KB
testcase_06 AC 2 ms
1,560 KB
testcase_07 AC 2 ms
1,556 KB
testcase_08 AC 2 ms
1,560 KB
testcase_09 AC 2 ms
1,556 KB
testcase_10 AC 2 ms
1,560 KB
testcase_11 AC 4 ms
1,560 KB
testcase_12 AC 2 ms
1,560 KB
testcase_13 AC 2 ms
1,560 KB
testcase_14 AC 1 ms
1,556 KB
testcase_15 AC 2 ms
1,560 KB
testcase_16 AC 1 ms
1,560 KB
testcase_17 AC 2 ms
1,560 KB
testcase_18 AC 2 ms
1,560 KB
testcase_19 AC 2 ms
1,560 KB
testcase_20 AC 2 ms
1,560 KB
testcase_21 AC 2 ms
1,560 KB
testcase_22 AC 2 ms
1,556 KB
testcase_23 AC 2 ms
1,556 KB
testcase_24 AC 1 ms
1,556 KB
testcase_25 AC 2 ms
1,556 KB
testcase_26 AC 2 ms
1,556 KB
testcase_27 AC 2 ms
1,560 KB
testcase_28 AC 2 ms
1,560 KB
testcase_29 AC 2 ms
1,556 KB
testcase_30 AC 1 ms
1,556 KB
testcase_31 AC 2 ms
1,560 KB
testcase_32 AC 2 ms
1,560 KB
testcase_33 AC 2 ms
1,556 KB
testcase_34 AC 2 ms
1,556 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:26:0: warning: "DEBUG1" redefined [enabled by default]
 #define DEBUG1 {}
 ^
main.cpp:21:0: note: this is the location of the previous definition
 #define DEBUG1(var0) { std::cerr << ( #var0 ) << "=" << ( var0 ) << endl; }
 ^
main.cpp:27:0: warning: "DEBUG2" redefined [enabled by default]
 #define DEBUG2 {}
 ^
main.cpp:22:0: note: this is the location of the previous definition
 #define DEBUG2(var0, var1) { std::cerr << ( #var0 ) << "=" << ( var0 ) << ", "; DEBUG1(var1); }
 ^
main.cpp:28:0: warning: "DEBUG3" redefined [enabled by default]
 #define DEBUG3 {}
 ^
main.cpp:23:0: note: this is the location of the previous definition
 #define DEBUG3(var0, var1, var2) { std::cerr << ( #var0 ) << "=" << ( var0 ) << ", "; DEBUG2(var1, var2); }
 ^
main.cpp:29:0: warning: "DEBUG4" redefined [enabled by default]
 #define DEBUG4 {}
 ^
main.cpp:24:0: note: this is the location of the previous definition
 #define DEBUG4(var0, var1, var2, var3) { std::cerr << ( #var0 ) << "=" << ( var0 ) << ", "; DEBUG3(var1, var2, var3); }
 ^

ソースコード

diff #
#include "bits/stdc++.h"
using namespace std;
//諸機能
#pragma region MACRO
#define ANSWER(x) cerr << "answer: "; cout << (x) << endl
#define D_ANSWER(x) cerr << "answer: "; cout << setprecision(10) << (double)(x) << endl
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define RREP(i,a,n) for(int i=(int)(a); i>= n; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) begin((a)),end((a))
#define FILL(a,n) for(auto &hoge : (a)) hoge = (n)
#define mp make_pair
#define EXIST(container, n) ((container).find((n)) != (container).end())
#define substr(s,i,l) string((s), (i), (l))
#define NPI_TO_RAD(x) (180.0*x/PI)
#define RAD_TO_NPI(x) (PI/180.0*x)
#pragma endregion
//デバッグなどの支援
#pragma region CODING_SUPPORT
#define DEBUG1(var0) { std::cerr << ( #var0 ) << "=" << ( var0 ) << endl; }
#define DEBUG2(var0, var1) { std::cerr << ( #var0 ) << "=" << ( var0 ) << ", "; DEBUG1(var1); }
#define DEBUG3(var0, var1, var2) { std::cerr << ( #var0 ) << "=" << ( var0 ) << ", "; DEBUG2(var1, var2); }
#define DEBUG4(var0, var1, var2, var3) { std::cerr << ( #var0 ) << "=" << ( var0 ) << ", "; DEBUG3(var1, var2, var3); }
#ifndef _DEBUG //デバッグでないなら、計算時間短縮のためにエラー出力を無効化
#define DEBUG1 {}
#define DEBUG2 {}
#define DEBUG3 {}
#define DEBUG4 {}
#endif 
#pragma endregion 
//typedef(書き換える、書き足す可能性ある)
#pragma region TYPE_DEF
typedef long long ll; 
typedef pair<int,int> pii;
typedef pair<string,string> pss;
typedef pair<int,string>pis;
typedef pair<string,int>psi;
typedef vector<string> vs;
typedef vector<int> vi;
#pragma endregion
//諸々の定数(書き換える可能性ある)
#pragma region CONST_VAL
#define PI (2*acos(0.0))
#define EPS (1e-9)
#define MOD (int)(1e9 + 7)
#pragma endregion

int main()
{
	ll n, m; cin >> n >> m;
	ll fib[80];
	ll rightm;
	fib[1] = fib[0] = 1;
	REP(i,2, 80)
	{
		fib[i] = fib[i - 1] + fib[i - 2];
	}
	rightm = fib[n-1];
	ll sa = rightm - m;
	if (sa < 0)
	{
		ANSWER(-1);
		return 0;
	}
	int count = 0;
	RREP(i,n-3 ,0)
	{
		if (sa >= fib[i])
		{
			sa -= fib[i];
			DEBUG2(sa,fib[i]);
			count++;
		}
	}
	ANSWER(count);
	return 0;
}

0