結果

問題 No.1286 Stone Skipping
ユーザー ShibuyapShibuyap
提出日時 2020-12-09 11:48:05
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 925 bytes
コンパイル時間 2,080 ms
コンパイル使用メモリ 201,560 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-19 04:48:43
合計ジャッジ時間 7,109 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 TLE -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(ll i = 0; i < (n); ++i)
#define srep(i,s,t) for (ll i = s; i < t; ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("YES");}else{puts("NO");}
#define MAX_N 200005
ll ans;

void dfs(ll d, ll k, ll ma, ll tmp){
    if(ma<0){
        if(d == 0){
            ans = min(ans, tmp);
        }
        return;
    }

    while(ma>=0){
        ll dd = d;
        ll ttmp = tmp + (1LL<<ma);
        rep(i,k){
            dd -= (1LL<<(ma-i));
            if(dd<0)break;
            if(ma-i==0)break;
        }
        if(dd==0){
            ans = min(ans, ttmp);
        }else if(dd>0){
            dfs(dd,k,ma-1,ttmp);
        }
        ma--;
    }
}

int main() {
    ll D;
    cin >> D;
    ans = D;

    srep(i,2,61){
        dfs(D,i,62,0);
    }

    cout << ans << endl;
    return 0;
}
 
 
0