結果

問題 No.648  お や す み 
ユーザー youthfuldays072
提出日時 2019-07-20 02:49:13
言語 C++14
(gcc 8.2.0)
結果
WA   .
実行時間 -
コード長 2,172 Byte
コンパイル時間 668 ms
使用メモリ 5,060 KB
最終ジャッジ日時 2019-07-20 02:49:15

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
10_small1.txt WA -
10_small2.txt WA -
10_small3.txt WA -
10_small4.txt WA -
10_small5.txt WA -
10_small6.txt WA -
10_small7.txt WA -
10_small8.txt WA -
10_small9.txt WA -
10_small10.txt WA -
20_medium1.txt WA -
20_medium2.txt WA -
20_medium3.txt WA -
20_medium4.txt WA -
20_medium5.txt WA -
20_medium6.txt WA -
20_medium7.txt WA -
20_medium8.txt WA -
20_medium9.txt WA -
20_medium10.txt WA -
20_medium11.txt WA -
20_medium12.txt WA -
20_medium13.txt WA -
20_medium14.txt WA -
20_medium15.txt WA -
20_medium16.txt WA -
20_medium17.txt WA -
20_medium18.txt WA -
20_medium19.txt WA -
20_medium20.txt WA -
30_large1.txt WA -
30_large2.txt WA -
30_large3.txt WA -
30_large4.txt WA -
30_large5.txt WA -
30_large6.txt WA -
30_large7.txt WA -
30_large8.txt WA -
30_large9.txt WA -
30_large10.txt WA -
40_verylarge1.txt WA -
40_verylarge2.txt WA -
40_verylarge3.txt WA -
40_verylarge4.txt WA -
40_verylarge5.txt WA -
40_verylarge6.txt WA -
40_verylarge7.txt WA -
40_verylarge8.txt WA -
40_verylarge9.txt WA -
40_verylarge10.txt WA -
40_verylarge11.txt WA -
40_verylarge12.txt WA -
40_verylarge13.txt WA -
40_verylarge14.txt WA -
40_verylarge15.txt WA -
40_verylarge16.txt WA -
40_verylarge17.txt WA -
40_verylarge18.txt WA -
40_verylarge19.txt WA -
40_verylarge20.txt WA -
50_veryverylarge1.txt WA -
50_veryverylarge2.txt WA -
50_veryverylarge3.txt WA -
50_veryverylarge4.txt WA -
50_veryverylarge5.txt WA -
50_veryverylarge6.txt WA -
50_veryverylarge7.txt WA -
50_veryverylarge8.txt WA -
50_veryverylarge9.txt WA -
50_veryverylarge10.txt WA -
99_corner1.txt WA -
99_corner2.txt WA -
99_corner3.txt WA -
99_corner4.txt WA -
99_corner5.txt WA -
99_corner6.txt WA -
99_corner7.txt WA -
99_corner11.txt WA -
99_corner12.txt WA -
99_corner13.txt WA -
99_corner14.txt WA -
99_corner15.txt WA -
99_system_test1.txt WA -
99_system_test2.txt WA -
テストケース一括ダウンロード

ソースコード

diff #
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

LL s;

bool isOK(LL index) {
	return (index ^ 2 + index - 2 * s) == 0;
}

LL bs() {
	LL ng = -1;
	LL ok = 2 * 1e18;

	while (abs(ok - ng) > 1) {
		LL mid = (ok + ng) / 2;

		if (isOK(mid))ok = mid;
		else ng = mid;
	}

	return ok;
}

int main() {
	LL s; cin >> s;

	cout << bs() << endl;
	return 0;
}
0