結果
| 問題 |
No.1286 Stone Skipping
|
| コンテスト | |
| ユーザー |
mine691
|
| 提出日時 | 2020-09-30 05:25:01 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 805 bytes |
| コンパイル時間 | 1,947 ms |
| コンパイル使用メモリ | 196,088 KB |
| 最終ジャッジ日時 | 2025-01-14 23:37:22 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 WA * 3 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = int_fast64_t;
constexpr int mod = 1e9 + 7;
constexpr int inf = (1 << 30) - 1;
constexpr ll infll = (1LL << 61) - 1;
#define fast() ios::sync_with_stdio(false), cin.tie(nullptr)
#define set_digit(N) cout << fixed << setprecision((N))
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
ll func(ll x, int k)
{
ll sum = 0;
while (k--)
{
sum += x;
x /= 2;
}
return sum;
}
int main()
{
ll D, ans = infll;
cin >> D;
int k = log2(D);
if ((1LL << k) == D)
return 0;
for (ll i = 0; i <= log2(D) + 1; i++)
{
ll ng = 0, ok = D;
while (ok - ng > 1)
{
ll mid = (ok + ng) / 2;
(func(mid, i) >= D ? ok : ng) = mid;
}
if (func(ok, i) == D)
ans = min(ans, ok);
}
cout << ans << "\n";
}
mine691