Codeforces 689c-mike and chocolate thieves

Source: Internet
Author: User

Test instructions: There are four thieves to steal chocolate, each small secret chocolate is the former thief K times. Example: A,ak,ak^2,ak^3. Then give your thief Head chocolate scheme number, Q: Under the conditions, the maximum amount of chocolate in the backpack is the minimum.

Analysis: Minimum maximum value. So two minutes n.

1 /************************************************2 Author:D Arktong3 Created TIME:2016/7/7 17:06:124 File name:c.cpp5 *************************************************/6 7#include <cstdio>8#include <cstring>9#include <iostream>Ten#include <algorithm> One#include <vector> A#include <queue> -#include <Set> -#include <map> the#include <string> -#include <cmath> -#include <cstdlib> -#include <ctime> +  - #defineINF 0x3f3f3f3f + #defineESP 1e-9 AtypedefLong Longll; at using namespacestd; - ll M; - ll Check (ll x) - { -ll sum=0; -      for(LL i=2;; ++i) in     { -         if(X<i*i*i) Break; tosum+=x/(i*i*i); +     } -     returnsum; the } * ll BS () $ {Panax Notoginsengll l=0, r=0x7fffffffffffffff; - ll T, Mid; the      while(l<R) +     { AMid = (l+r+1)/2; thet =Check (mid); + //cout<< "T:" <<t<< "L:" <<L<< "R:" <<R<<endl; -         if(t==m) Break; $         Else if(t>m) r=mid-1; $         ElseL=mid+1; -     } -     if(t==m)returnmid; the     Else return-1; - }Wuyi voidSolve (ll x) the { - //< cout<< "x:" <<x<<endl; Wu     if(x==-1) puts ("-1"); -     Else About     { $ll Ma=0; -          for(LL i=2;; ++i) -         { -             if(X<i*i*i) Break; AMA = Max (MA, (x/(i*i*i) *i*i*i)); +         } thecout<<ma<<Endl; -     } $ } the  the  the intMain () the { -     //freopen ("In.txt", "R", stdin); in     //freopen ("OUT.txt", "w", stdout); thescanf"%lld", &m); the Solve (BS ()); About     return 0; the}

Codeforces 689c-mike and chocolate thieves

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.