結果
| 問題 | 
                            No.1286 Stone Skipping
                             | 
                    
| コンテスト | |
| ユーザー | 
                             tnakao0123
                         | 
                    
| 提出日時 | 2020-11-14 16:56:15 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 2 ms / 2,000 ms | 
| コード長 | 1,142 bytes | 
| コンパイル時間 | 716 ms | 
| コンパイル使用メモリ | 93,504 KB | 
| 実行使用メモリ | 6,948 KB | 
| 最終ジャッジ日時 | 2024-07-23 09:57:59 | 
| 合計ジャッジ時間 | 1,552 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 26 | 
ソースコード
/* -*- coding: utf-8 -*-
 *
 * 1286.cc:  No.1286 Stone Skipping - yukicoder
 */
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;
/* constant */
const int MAX_N = 100;
const int MAX_K = 63;
/* typedef */
typedef long long ll;
/* global variables */
/* subroutines */
ll check(int k, ll x, ll d) {
  ll sum = 0;
  for (int i = 0; x > 0 && i < k; i++, x >>= 1) {
    sum += x;
    if (sum > d) return sum;
  }
  return sum;
}
/* main */
int main() {
  ll d;
  scanf("%lld", &d);
  //for (int k = 0; d > 0 && k < MAX_K; k++, d /= 2) printf("%d %lld\n", k, d);
  ll minx = d;
  for (int k = 2; k <= MAX_K; k++) {
    ll x0 = 0, x1 = d;
    while (x0 + 1 < x1) {
      ll x = (x0 + x1) / 2;
      if (check(k, x, d) >= d) x1 = x;
      else x0 = x;
    }
    if (check(k, x1, d) == d && minx > x1) minx = x1;
  }
  printf("%lld\n", minx);
  return 0;
}
            
            
            
        
            
tnakao0123