689C - Mike and Chocolate Thieves 二分
题目大意:有四个小偷,第一个小偷偷a个巧克力,后面几个小偷依次偷a*k,a*k*k,a*k*k*k个巧克力,现在知道小偷有n中偷法,求在这n种偷法中偷得最多的小偷的所偷的最小值。
题目思路:二分查找偷得最多的小偷所偷的数目,并遍历k获取该数目下的方案数。脑子一抽将最右端初始化做了1e15,wa了n多次……
#include<iostream>
#include<algorithm>
#include<cstring>
#include<vector>
#include<stdio.h>
#include<stdlib.h>
#include<queue>
#include<math.h>
#include<map>
#define INF 0xffffffff
#define MAX 1e18
#define Temp 1000000000
#define MOD 1000000007 using namespace std; long long n;
int ok; long long Check(long long m)
{
long long ans=;
for(long long i=;i*i*i<=m;i++)
{
ans+=(m/(i*i*i));
}
return ans;
} long long Find()
{
long long L=,R=MAX,ans;
while(L<=R)
{
long long Mid=(L+R)/;
long long t =Check(Mid);
if(t > n)
R=Mid-;
else if(t < n)
L=Mid+;
else
{
ok=;
ans=Mid;
R=Mid-;
} }
return ans;
} int main()
{
while(scanf("%lld",&n)!=EOF)
{
ok=;
long long ans=Find();
if(!ok)
printf("-1\n");
else
printf("%lld\n",ans);
}
return ;
}
689C - 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 689C Mike and Chocolate Thieves (二分+数论)
Mike and Chocolate Thieves 题目链接: http://acm.hust.edu.cn/vjudge/contest/121333#problem/G Description ...
- codeforces 689C C. Mike and Chocolate Thieves(二分)
题目链接: C. Mike and Chocolate Thieves time limit per test 2 seconds memory limit per test 256 megabyte ...
- 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 ...
- 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,问能不能求得一个最小的整 ...
- codeforces 361 C - Mike and Chocolate Thieves
Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u Description Bad ...
随机推荐
- Class.forName()
主要功能 Class.forName(xxx.xx.xx)返回的是一个类 Class.forName(xxx.xx.xx)的作用是要求JVM查找并加载指定的类, 也就是说JVM会执行该类的静态代码段 ...
- Java comparable 和 comparator
一.comparator 接口继承 public class ComparatorTest { /** * @param args */ public static void main(String[ ...
- python 列表、字典的方法
# 列表最后新增元素 li = [11, 22, 33] print(li) li.append(44) # 对原列表最后增加一个元素 print(li) 执行如下: [11, 22, 33][11, ...
- javascript动画效果之透明度(修改版)
在编写多块同时触发运动的时候,发现一个BUG, timer = setInterval(show, 30);本来show是一个自定义函数,当设为timer = setInterval(show(one ...
- IE/Chrome背景图片居中1px偏移解决方法
最近在支持行业运营的一个推广页面,遇到了非常规的页面banner图居中的问题,为了解决此问题,做了简单的测试,做了一个小结,为经常做大促页面的兄弟姐妹们提供参考解决方案. 首先来看看现象.最经典的页面 ...
- 9.创建一个三角形类,成员变量三边,方法求周长,创建类主类A来测试它。
package com.hanqi.test; public class Triangle { private double a,b,c; public Triangle(double d,doubl ...
- HDU 3410 Passing the Message
可以先处理出每个a[i]最左和最右能到达的位置,L[i],和R[i].然后就只要询问区间[ L[i],i-1 ]和区间[ i+1,R[i] ]最大值位置即可. #include<cstdio&g ...
- Educational Codeforces Round 15_C. Cellular Network
C. Cellular Network time limit per test 3 seconds memory limit per test 256 megabytes input standard ...
- Entity Framework技巧系列之五 - Tip 16 – 19
提示16. 当前如何模拟.NET 4.0的ObjectSet<T> 背景: 当前要成为一名EF的高级用户,你确实需要熟悉EntitySet.例如,你需要理解EntitySet以便使用 At ...
- AC Me
AC Me Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other) Total Submiss ...