链接:戳这里

C. Mike and Chocolate Thieves
time limit per test2 seconds
memory limit per test256 megabytes
inputstandard input
outputstandard 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 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.

Examples
input
1
output
8
input
8
output
54
input
10
output
-1
Note
In the first sample case the smallest n that leads to exactly one way of stealing chocolates is n = 8, whereas the amounts of stealed chocolates are (1, 2, 4, 8) (the number of chocolates stolen by each of the thieves).

In the second sample case the smallest n that leads to exactly 8 ways is n = 54 with the possibilities: (1, 2, 4, 8),  (1, 3, 9, 27),  (2, 4, 8, 16),  (2, 6, 18, 54),  (3, 6, 12, 24),  (4, 8, 16, 32),  (5, 10, 20, 40),  (6, 12, 24, 48).

There is no n leading to exactly 10 ways of stealing chocolates in the third sample case.

题意:

给出一个数m,一个数x以k(k>1)倍增加三次形成四个数,所有的x及k都需要枚举到

问正好有m组这样的四元组所对应的最大的第四个数是多少

思路:

其实就是二分答案,然后判断这个数符合不符合条件

代码:

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string>
#include<vector>
#include <ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<iomanip>
#include<cmath>
#define mst(ss,b) memset((ss),(b),sizeof(ss))
#define maxn 0x3f3f3f3f
#define MAX 1000100
///#pragma comment(linker, "/STACK:102400000,102400000")
typedef long long ll;
typedef unsigned long long ull;
#define INF (1ll<<60)-1
using namespace std;
ll m;
ll a[200010];
ll solve(ll x){ll ans=0;for(int i=1;i<=200000;i++){ans+=x/a[i];if(ans>m) break;}return ans;
}
int main(){for(int i=1;i<=200000;i++) a[i]=(ll)(i+1)*(i+1)*(i+1);scanf("%I64d",&m);ll ans=-1,l=1,r=1e16,mid;while(l<r){mid=(l+r)/2;if(solve(mid)==m) {ans=mid;r=mid;}else if(solve(mid)<m){l=mid+1;}else r=mid;}printf("%I64d\n",ans);return 0;
}

Codeforces Round #361 (Div. 2) C 二分相关推荐

  1. 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 ...

  2. 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 ...

  3. Codeforces Round #361(div 2)

    A题题目意思很简单,问一种拨号的方式(拨号手势)是不是能拨出唯一的号码(例如253就不是唯一的,因为586也是可以的) 记录电话上每个格子上下左右是否还有格子,一个拨号手势是唯一的当且仅当,所拨号码的 ...

  4. Codeforces Round #593 (Div. 2) D. Alice and the Doll 暴力 + 二分

    传送门 文章目录 题意: 思路: 题意: 思路: 还以为这个题有什么高深的算法,结果就是个暴力. 由于n∗mn*mn∗m达到了1e101e101e10的级别,所以直接暴力肯定是不行的,考虑有很多空格, ...

  5. Codeforces Round #725 (Div. 3) G. Gift Set 二分

    传送门 文章目录 题意: 思路: 题意: 有两种物品分别有x,yx,yx,y个,每次可以从一个拿出aaa个,另一个拿出bbb个分成一组,问最多能分成多少组. 思路: 这个题有一个显然的单调性,所以二分 ...

  6. Codeforces Round #635 (Div. 2) D. Xenia and Colorful Gems 暴力 + 二分

    传送门 文章目录 题意: 思路: 题意: 给你三个数组a,b,ca,b,ca,b,c,让你从每个数组中选择一个数x,y,zx,y,zx,y,z,使得(x−y)2+(x−z)2+(y−z)2(x-y)^ ...

  7. Codeforces Round #696 (Div. 2) (A ~ E)超高质量题解(每日训练 Day.16 )

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 Codeforces Round #696 (Div. 2) (A ~ E)超高质量题解 比赛链接:h ...

  8. Codeforces Round #701 (Div. 2) A ~ F ,6题全,超高质量良心题解【每日亿题】2021/2/13

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 目录 A - Add and Divide B - Replace and Keep Sorted C ...

  9. Codeforces Round #514 (Div. 2)题解

    Codeforces Round #514 (Div. 2)题解 A 喵,直接模拟. B 枚举所有盖章时的,合法的,左上角的位置.能盖的话就盖一下.最后check一下图案是否相等即可 C 一轮一轮的扔 ...

最新文章

  1. VTK:网格之FillHoles
  2. ubuntu mysql环境变量配置_MySQL在Win10与Ubuntu下的安装与配置
  3. abaqus python 读取文件_通过Python脚本从Abaqus中的excel文件导入幅度数据
  4. 基于级联双向胶囊网络的鲁棒三元组知识抽取
  5. basis问题专区(文档)
  6. paip.提升用户体验----c++ 源码字体自定义制造总结
  7. 软考论文写作攻略,让你轻松拿高分!
  8. 摄影名词解释 (ISO、快门、光圈、曝光、测光与测光模式、曝光补偿、焦距、光学变焦与数码变焦、景深与光圈优先、白平衡与RAW)
  9. js替换url指定参数的值
  10. 深度学习21_李宏毅_04_Local Minimum And Saddle Point
  11. 读书笔记 | 4.1 信用报告及其国际比较
  12. 软件公司防止代码外泄的几种方法介绍
  13. 区块链之一 起源思想和本质
  14. 从入门到精通之专家系统CLIPS(一)CLIPS初识与概述
  15. IOS开发(17)IOS 使用LBXScan框架开发扫一扫功能
  16. Unity 理解预制体(Prefab)和预制体变体(PrefabVariant)
  17. db2 迁移 aix linux,DB2从windowsXP迁移至AIX完整过程
  18. 【01】软件项目管理结构图
  19. 【数值模型环境搭建】Intel编译器安装
  20. 开关电源方案 12V2A 或24v1A,EFD25磁芯,实测12V时可带2.4A

热门文章

  1. 2019年应届生校招技面随笔
  2. 下载学习通上没有下载权限的文件
  3. sparksteaming的idea配置及入门程序
  4. Python实现抓取微信公众号文章
  5. BUUCTF 打卡2
  6. 淘宝新手开店怎么做才能破零
  7. 淘宝天猫店招空白间隔去除
  8. 【电子产品】kindle使用心得.满满干货
  9. Kindle的使用体验
  10. Linux中shell的ls,linux系统shell中ls指令