結果
| 問題 | 
                            No.1286 Stone Skipping
                             | 
                    
| コンテスト | |
| ユーザー | 
                             startcpp
                         | 
                    
| 提出日時 | 2020-11-13 23:41:01 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                TLE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 648 bytes | 
| コンパイル時間 | 581 ms | 
| コンパイル使用メモリ | 63,232 KB | 
| 実行使用メモリ | 10,752 KB | 
| 最終ジャッジ日時 | 2024-07-22 22:18:33 | 
| 合計ジャッジ時間 | 5,097 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 21 TLE * 1 -- * 4 | 
ソースコード
//嘘解法っぽいものをあえて書いてみる
//ただ2分探索をしたら落ちますか?
#include <iostream>
#define int long long
using namespace std;
int f(int x) {
	int ret = 0;
	while (x > 0) {
		ret += x;
		x >>= 1;
	}
	return ret;
}
bool check(int x, int d) {
	int ret = 0;
	while (x > 0) {
		ret += x;
		if (ret == d) return true;
		x >>= 1;
	}
	return false;
}
signed main() {
	int d; cin >> d;
	
	int ng = 0, ok = d, mid;
	while (ok - ng >= 2) {
		mid = (ng + ok) / 2;
		if (f(mid) >= d) ok = mid;
		else ng = mid;
	}
	
	for (int i = ok; ; i++) {
		if (check(i, d)) {
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}
            
            
            
        
            
startcpp