codeforces 689C C. Mike and Chocolate Thieves(二分)
题目链接:
2 seconds
256 megabytes
standard input
standard output
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 fixedn, 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.
1
8
8
54
10
-1 题意: 现在有四个小偷,第一个小偷偷走x,第二个x*k,三个x*k*k,四个x*k*k*k;
现在知道一共有n种偷法,问小偷的背包的最小容量是多少; 思路: 二分最小容量,check看这个数能否有n种偷法; AC代码:
//#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <queue>
#include <cmath>
#include <map>
#include <cstring>
#include <algorithm>
#include <cstdio> using namespace std;
#define For(i,j,n) for(int i=j;i<=n;i++)
#define Riep(n) for(int i=1;i<=n;i++)
#define Riop(n) for(int i=0;i<n;i++)
#define Rjep(n) for(int j=1;j<=n;j++)
#define Rjop(n) for(int j=0;j<n;j++)
#define mst(ss,b) memset(ss,b,sizeof(ss));
typedef long long LL;
template<class T> void read(T&num) {
char CH; bool F=false;
for(CH=getchar();CH<''||CH>'';F= CH=='-',CH=getchar());
for(num=;CH>=''&&CH<='';num=num*+CH-'',CH=getchar());
F && (num=-num);
}
int stk[], tp;
template<class T> inline void print(T p) {
if(!p) { puts(""); return; }
while(p) stk[++ tp] = p%, p/=;
while(tp) putchar(stk[tp--] + '');
putchar('\n');
} const LL mod=1e9+;
const double PI=acos(-1.0);
const LL inf=1e18;
const int N=2e5+;
const int maxn=;
const double eps=1e-; LL m,dp[*N]; int check(LL x)
{
LL num=;
for(int i=;i<;i++)
{
if(dp[i]<=x)
{
num+=x/dp[i];
}
}
if(num>m)return ;
else if(num==m)return ;
return ;
}
void Init()
{
for(int i=;i<=;i++)
{
LL temp=i;
dp[i]=temp*temp*temp;
}
}
int main()
{
Init();
read(m);
LL l=,r=inf;
while(l<=r)
{
LL mid=(l+r)>>;
if(!check(mid))l=mid+;
else r=mid-;
}
if(check(l)==)cout<<l<<"\n";
else cout<<"-1"<<"\n";
return ;
}
codeforces 689C C. Mike and Chocolate Thieves(二分)的更多相关文章
- Codeforces 689C. Mike and Chocolate Thieves 二分
C. Mike and Chocolate Thieves time limit per test:2 seconds memory limit per test:256 megabytes inpu ...
- Codeforces Round #361 (Div. 2) C. Mike and Chocolate Thieves 二分
C. Mike and Chocolate Thieves 题目连接: http://www.codeforces.com/contest/689/problem/C Description Bad ...
- Codeforces Round #341 (Div. 2) C. Mike and Chocolate Thieves 二分
C. Mike and Chocolate Thieves time limit per test 2 seconds memory limit per test 256 megabytes inpu ...
- 689C - Mike and Chocolate Thieves 二分
题目大意:有四个小偷,第一个小偷偷a个巧克力,后面几个小偷依次偷a*k,a*k*k,a*k*k*k个巧克力,现在知道小偷有n中偷法,求在这n种偷法中偷得最多的小偷的所偷的最小值. 题目思路:二分查找偷 ...
- codeforces 361 C - Mike and Chocolate Thieves
Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u Description Bad ...
- CodeForces 689C Mike and Chocolate Thieves (二分+数论)
Mike and Chocolate Thieves 题目链接: http://acm.hust.edu.cn/vjudge/contest/121333#problem/G Description ...
- CodeForces 689C Mike and Chocolate Thieves (二分)
原题: Description Bad news came to Mike's village, some thieves stole a bunch of chocolates from the l ...
- CodeForces 689C Mike and Chocolate Thieves (二分最大化最小值)
题目并不难,就是比赛的时候没敢去二分,也算是一个告诫,应该敢于思考…… #include<stdio.h> #include<iostream> using namespace ...
- CodeForces 689C Mike and Chocolate Thieves
题目链接:http://acm.hust.edu.cn/vjudge/problem/visitOriginUrl.action?id=412145 题目大意:给定一个数字n,问能不能求得一个最小的整 ...
随机推荐
- 自动化测试-selenium IDE使用
selenium IDE结合浏览器提供脚本的录制,回放以及编辑脚本功能,以及元素的定位,可以使用selenium IDE将录制的脚本生成相应的带单元测试框架的自动化测试脚本. selenium具有录制 ...
- xtu字符串 C. Marlon's String
C. Marlon's String Time Limit: 2000ms Memory Limit: 65536KB 64-bit integer IO format: %lld Java ...
- [MGR——Mysql的组复制之多主模式 ] 详细搭建部署过程
组复制可以在两种模式下运行. 1.在单主模式下,组复制具有自动选主功能,每次只有一个 server成员接受更新.2.在多主模式下,所有的 server 成员都可以同时接受更新. 组复制与异步主从复 ...
- vue2.0单元测试(一)
1.在vue init webpack XXX创建项目的时候 最后2步选择YES就启动了vue单元测试开始了 2.测试是使用karma+mocha框架来实现的方法,安装虚拟浏览器模块Phantom ...
- Linux终端Shell下的常用快捷键收集
删除 [Ctrl]+[D]删除光标所在位置上的字符相当于VIM里x或者dl [Ctrl]+[H]删除光标所在位置前的字符相当于VIM里hx或者dh [Ctrl]+[K]删除光标后面所有字符相当于VIM ...
- 关于maven多个模块的build顺序 [INFO] Reactor Build Order
对于一个maven项目,如果有多个模块,那么它们的执行顺序是什么样的呢? 在执行mvn操作的时候,你可以看到如下信息,这个便是maven的build顺序 那么maven是如何决定顺序的呢?如下: 在多 ...
- 【Todo】开个文章学VUE咯
2017年FE架构组制定的框架选型主导为VUE.看了一下VUE的介绍,很不错. 开学~ https://www.zhihu.com/question/38213423 这个里面有VUE应用和背景的一些 ...
- Eclipse luna 装不上 veloeclipse
今天在Eclipse中始终无法安装veloeclipse ,报错:Failed to prepare partial IU: [R]com.googlecode.veloeclipse.ui 2.0. ...
- 跟着9张思维导图学JavaScript
思维导图小tips 思维导图又叫心智图,是表达发射性思维的有效的图形思维工具 ,它简单却又极其有效,是一种革命性的思维工具.思维导图运用图文并重的技巧,把各级主题的关系用相互隶属与相关的层级图表现出来 ...
- Java 实现桥接(Bridge)模式
类图: watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvamp3d21scDQ1Ng==/font/5a6L5L2T/fontsize/400/fill/I0 ...