Cf 361div2 C [二分]

原创 2016年08月30日 23:49:48



Bad news came to Mike’s village, some thieves stole a bunch of chocolates from the local factory! Horrible!

Aside from loving sweet things, thieves from this area are known to be very greedy. So after a thief takes his number of chocolates for himself, the next thief will take exactly k times more than the previous one. The value of k (k > 1) is a secret integer known only to them. It is also known that each thief’s bag can carry at most n chocolates (if they intend to take more, the deal is cancelled) and that there were exactly four thieves involved.

Sadly, only the thieves know the value of n, but rumours say that the numbers of ways they could have taken the chocolates (for a fixed n, but not fixed k) is m. Two ways are considered different if one of the thieves (they should be numbered in the order they take chocolates) took different number of chocolates in them.

Mike want to track the thieves down, so he wants to know what their bags are and value of n will help him in that. Please find the smallest possible value of n or tell him that the rumors are false and there is no such n.


The single line of input contains the integer m (1 ≤ m ≤ 1015) — the number of ways the thieves might steal the chocolates, as rumours say.


Print the only integer n — the maximum amount of chocolates that thieves’ bags can carry. If there are more than one n satisfying the rumors, print the smallest one.
If there is no such n for a false-rumoured m, print  - 1.

Sample Input


Sample Output







using namespace std;
#define ll long long
ll n;
const ll INF=1e16;
ll solve(ll x)
{   ll num=0;
    for(ll k=2;k<=x;k++)
            else break;

    return num;

int main()

    ll ans=INF;
    ll le=1,ri=INF,mi;
    for(int i=0;i<100;i++)
    {   mi=(le+ri)/2;
        ll jj=solve(mi);
        else if(jj<n)le=mi;
        else ri=mi;
//    ll le=0,ri=1e16,mi;
//    while(le<=ri)
//    {
//        mi=(le+ri)/2;
//        if()le=mi+1;
//        ri=mi-1
//    }
    else printf("%I64d\n",ans);
    return 0;

Codeforces 689C Mike and Chocolate Thieves (二分)

Codeforces 689C Mike and Chocolate Thieves (二分)
  • Tc_To_Top
  • Tc_To_Top
  • 2016年07月10日 21:15
  • 596

【打CF,学算法——三星级】CodeForces 689C Mike and Chocolate Thieves (二分)

题目链接:CF 689C 题面: C. Mike and Chocolate Thieves time limit per test 2 seconds memory limit ...
  • David_Jett
  • David_Jett
  • 2016年07月08日 10:55
  • 864

Codeforces 689.C Mike and Chocolate Thieves 二分+数学

二分专题 二分+数学
  • qq_26071477
  • qq_26071477
  • 2016年07月12日 22:21
  • 780

Codeforces Round #361 (Div. 2) C. Mike and Chocolate Thieves(二分判断)

Bad news came to Mike's village, some thieves stole a bunch of chocolates from the local factory! Ho...
  • u014258433
  • u014258433
  • 2016年07月18日 22:44
  • 166

Codeforces Round #361 (Div. 2) C - Mike and Chocolate Thieves

C. Mike and Chocolate Thieves time limit per test 2 seconds memory limit per test 256 megaby...
  • Ginray
  • Ginray
  • 2016年07月07日 15:47
  • 579

【CF】Codeforces Round #361 (Div. 2)

难得有想法写一整套题解 首先想说的是,这场CF,我感觉是div2极为不错的一场(对于中档选手 说笑了,感觉这一场很耐人寻味。就是那种抓破头皮想不出,知道做法后细细品味,有种   哦~~~~~这样啊...
  • ChallengerRumble
  • ChallengerRumble
  • 2016年07月09日 17:06
  • 1515

Codeforces #361 D Mike and Chocolate Thieves(二分+数学)

题意大体是有四个小偷去偷巧克力,四个人偷巧克力的个数是一个等比数列,输入四个小偷可能的n种方案,输出最小的符合这个方案的所有等比数列的最大值 这道题自己在二分的时候老是遇到浮点数的报错问题,千辛万苦的...
  • Mandsnow
  • Mandsnow
  • 2016年07月20日 18:54
  • 174

cf 689 C(二分)

链接: #include using namespace std; #define ll lon...
  • a73265
  • a73265
  • 2016年07月12日 19:14
  • 120

cf 551 C(二分)

链接:          思路:二分查找所需的时间t,m个人都有t个单位的时间,从后往前清空,直到答案...
  • a73265
  • a73265
  • 2016年07月12日 18:32
  • 180

cf 670D2 Magic Powder - 2 二分裸题

D2. Magic Powder - 2 time limit per test1 second memory limit per test256 megabytes inputstandard...
  • ctrss
  • ctrss
  • 2016年05月12日 00:22
  • 462
您举报文章:Cf 361div2 C [二分]