結果
| 問題 | No.1286 Stone Skipping |
| コンテスト | |
| ユーザー |
Example0911
|
| 提出日時 | 2020-11-13 22:00:42 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 782 bytes |
| コンパイル時間 | 1,866 ms |
| コンパイル使用メモリ | 192,016 KB |
| 最終ジャッジ日時 | 2025-01-15 22:56:57 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 19 WA * 7 |
ソースコード
#include "bits/stdc++.h"
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
long long d;
bool f(long long x) {
if (x == d)return true;
long long now = x;
while (x > 0) {
now += x / 2;
if (now == d)return true;
x /= 2;
}
now += x;
if (now == d)return true;
return false;
}
int main() {
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
cin >> d;
long long ans = d;
long long tmp = 1;
long long bunsi = 1, bunbo = 1;
for (int i = 0; bunsi <= (1e18+100); i++) {
double tmp2 = (double)bunbo / (double)bunsi;
tmp2 *= (double)d;
long long now = (long long)tmp2;
for (long long j = now - 5; j <= now + 5; j++) {
if (f(j)) {
ans = min(ans, j);
}
}
tmp *= 2;
bunsi += tmp; bunbo = tmp;
}
cout << ans << endl;
return 0;
}
Example0911