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 ...
随机推荐
- 渗透测试的WINDOWS NTFS技巧集合
译者:zzzhhh 这篇文章是来自SEC Consult Vulnerability Lab的ReneFreingruber (@ReneFreingruber),分享了过去几年从各种博客文章中收集的 ...
- 【C++】数组-二分法查找
1.原理 对于给定值的查找,如果大于该数组的中间元素,下一步在元素值大的区域继续与其中间元素比较:否则下一步在元素值小的区域内继续查找,直到找到目标元素.如果到最后还没有找到,则输出"数组中 ...
- Memcached服务器UDP反射放大攻击
1.前言 2月28日,Memcache服务器被曝出存在UDP反射放大攻击漏洞.攻击者可利用这个漏洞来发起大规模的DDoS攻击,从而影响网络正常运行.漏洞的形成原因为Memcache 服务器UDP 协议 ...
- git本地分支和远程分支改名
#1 将本地分支进行改名 git branch -m old_branch new_branch #2 将远程分支的老分支删除 git push origin :old_branch #3 将改名后的 ...
- ASP .NET Core 2.0 MVC 发布到 IIS 上以后 无法下载apk等格式的文件
ASP .NET Core MVC 发布到 IIS 上以后 无法下载apk等格式的文件 使用.NET Core MVC创建了一个站点,其他文件可以下载,但是后来又需求,就把手机端的apk合适的文件上 ...
- 如何查看页面是否开启了gzip压缩
1.谷歌浏览器 F12 2.在表头单击鼠标右键 3.如果开启了gzip则显示gzip,没有则是空
- LCT解读(1)
蒟蒻的LCT解读(1) 前段时间本蒟蒻自学了一下LCT,但是网上的很多资料并不很全,而且作为一个数组选手,我看指针代码真的很麻烦,所以就在这里写一篇数组选手能看懂的代码. LCT的初步了解 LCT全称 ...
- maven pom.xml配置
<repositories> <repository> <id>central</id> <name>Maven Repository Sw ...
- JAVA复习笔记之GC部分
前言:垃圾回收机制,大家都知道JAVA的垃圾回收都是JVM自动回收的,不需要程序员去管理.但是我们还是得知道原理才能在适当时机进行JVM调优 原理:当我们new 一个对象时JVM堆区就会分配一块 ...
- LeetCode282. Expression Add Operators
Given a string that contains only digits 0-9 and a target value, return all possibilities to add bin ...