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 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.
Input
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.
Output
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
8
Sample Output
54
Hint
题意
给你n,让你找到一个最小的数t,使得这个数t以内,恰好存在n个四元组
这个四元组需要满足 a,ak,ak2,ak3,且这四个数都小于等于t
题解
二分答案,然后我们暴力枚举k,然后算四元组有多少个就好了。
代码
#include<bits/stdc++.h>
using namespace std;
long long n;
long long mul(long long x){
return x*x*x;
}
long long cal(long long k){
long long sum = 0;
for(int i=2;i<=1e6;i++)
sum+=k/mul(i);
return sum;
}
int main(){
cin>>n;
long long l = 0,r = 1e18;
while(l<=r){
long long mid=(l+r)/2;
if(cal(mid)>=n)r=mid-1;
else l=mid+1;
}
if(cal(r+1)==n)cout<<r+1<<endl;
else cout<<"-1"<<endl;
}
Codeforces Round #361 (Div. 2) C. Mike and Chocolate Thieves 二分的更多相关文章
- 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 ...
- Codeforces Round #361 (Div. 2) E. Mike and Geometry Problem 离散化 排列组合
E. Mike and Geometry Problem 题目连接: http://www.codeforces.com/contest/689/problem/E Description Mike ...
- Codeforces Round #361 (Div. 2) B. Mike and Shortcuts bfs
B. Mike and Shortcuts 题目连接: http://www.codeforces.com/contest/689/problem/B Description Recently, Mi ...
- Codeforces Round #361 (Div. 2) A. Mike and Cellphone 水题
A. Mike and Cellphone 题目连接: http://www.codeforces.com/contest/689/problem/A Description While swimmi ...
- Codeforces Round #361 (Div. 2) E. Mike and Geometry Problem 【逆元求组合数 && 离散化】
任意门:http://codeforces.com/contest/689/problem/E E. Mike and Geometry Problem time limit per test 3 s ...
- Codeforces Round #361 (Div. 2) E. Mike and Geometry Problem 离散化+逆元
E. Mike and Geometry Problem time limit per test 3 seconds memory limit per test 256 megabytes input ...
- Codeforces Round #361 (Div. 2)——B. Mike and Shortcuts(BFS+小坑)
B. Mike and Shortcuts time limit per test 3 seconds memory limit per test 256 megabytes input standa ...
- Codeforces Round #361 (Div. 2)A. Mike and Cellphone
A. Mike and Cellphone time limit per test 1 second memory limit per test 256 megabytes input standar ...
- Codeforces Round #361 (Div. 2) E. Mike and Geometry Problem
题目链接:传送门 题目大意:给你n个区间,求任意k个区间交所包含点的数目之和. 题目思路:将n个区间都离散化掉,然后对于一个覆盖的区间,如果覆盖数cnt>=k,则数目应该加上 区间长度*(cnt ...
随机推荐
- 一个脚本和一个容易疏忽的问题strcmp、strncmp、memcmp的用法【原创】
一个容易疏忽的问题: strcmp.strncmp.memcmp, 对于memcmp进行字符串比较时可能会出现内存重叠的情况 status = strncmp(xdev->product, &q ...
- RabbitMQ--Publish/Subscribe(三)
前言 在先前例子中我们创建了一个work queue,封装一个task到一个message中并发送到queue.一个worker(consumer)取出任务并执行. 像这种producer把messa ...
- 前端程序员必知的30个Chrome扩展-[转载]
谷歌Chrome浏览器是网络上可用的最好浏览器之一,并且自2011年11月超越了Firefox浏览器之后,已经成为了互联网上占主导地位的浏览器.今天,HTML5中国与大家分享一些实用的谷歌Chrome ...
- Centos中查询目录中内容命名ls
首先解释下这块, root代表当前登录用户,localhost代表主机名, ~代表当前主机目录, #代表用户权限 #表示超级用户,$表示普通用户: 查询目录中内容命令 ls (list缩写) ...
- 安装SHARP MX-3618NC PCL6打印机驱动程序
第一步, 打开MX-CR3_PCL_PS_1302a_ChineseS_Win8Server2012.exe 驱动程序 此驱动支持Win8.Server2012及以下版本的操作系统,同时兼容Win1 ...
- 自动化CI构建工具
hudson/maven jenkins,bamboo, hudson
- LoadRunner中log的使用总结
LoadRunner中log的使用总结 1.log的设置方式. 在 runtime setting中可以设置log的生成方式: 默认的log方式: Enable logging选中,log optio ...
- caffe中根据 *_train_test.prototxt文件生成 *_deploy.prototxt文件 (转载)
见博客:http://blog.csdn.net/u010417185/article/details/52137825
- 2017-2018-1 20179202《Linux内核原理与分析》第十一周作业
Metasploit实现木马生成.捆绑.免杀 1.预备知识 (1)Metasploit Metasploit是一款开源的安全漏洞检测工具,全称叫做The Metasploit Framework,简称 ...
- 创建 python 虚拟环境
conda 创建环境 conda 可以理解为一个工具,也是一个可执行命令,其核心功能是包管理与环境管理.包管理与 pip 的使用类似,环境管理则允许用户方便地安装不同版本的 python 并可以快速切 ...