(二分)Block Towers(cf626)
http://www.codeforces.com/contest/626/problem/C
题意是有一群小朋友在堆房子,现在有n个小孩每次可以放两个积木,m个小孩,每次可以放3个积木,最后每个小孩堆得高度都不同,求最大的高度最小是多少;
例如n = 4,m = 2;
所有高度分别为2,4,6,8, 3,9;所以答案是9;
我们可以用二分搜索答案,当num满足所有高度都不同时,必须满足num以内的2的倍数的个数大于n,3的倍数的个数大于m,2的倍数的个数+3的倍数的个数-6的倍数的个数大于m+n;
所以只要我们找到最小的num即可;
盗队友的代码,我原本的思路和她的是不相同的, 感觉她的思路很不错,就盗回来学习一下吧!!!
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <map>
#include <vector>
using namespace std;
typedef long long LL;
#define PI 4*atan(1.0)
#define N 550
#define met(a, b) memset(a, b, sizeof(a)) int main()
{
int n, m;
while(scanf("%d %d", &n, &m)!=EOF)
{
int L = , R = , ans;
while(L<=R)
{
int Mid = (L+R)/;
if(Mid/>=n && Mid/>=m && Mid/+Mid/-Mid/>=m+n)
R = Mid-, ans = Mid;
else
L = Mid+;
}
printf("%d\n", ans);
}
return ;
}
(二分)Block Towers(cf626)的更多相关文章
- codeforce626C.Block Towers(二分)
C. Block Towers time limit per test 2 seconds memory limit per test 256 megabytes input standard inp ...
- Codeforces 626C Block Towers(二分)
C. Block Towers time limit per test:2 seconds memory limit per test:256 megabytes input:standard inp ...
- 8VC Venture Cup 2016 - Elimination Round C. Block Towers 二分
C. Block Towers 题目连接: http://www.codeforces.com/contest/626/problem/C Description Students in a clas ...
- Codeforces 626C Block Towers「贪心」「二分」「数学规律」
题意: 一堆人用方块盖塔,有n个人每次只能加两块方块,有m个人每次只能加三块方块.要求每个人盖的塔的高度都不一样,保证所用方块数最少,求最高的塔的高度. 0<=n+m 0<=n,m< ...
- 8VC Venture Cup 2016 - Elimination Round (C. Block Towers)
题目链接:http://codeforces.com/contest/626/problem/C 题意就是给你n个分别拿着2的倍数积木的小朋友和m个分别拿着3的倍数积木的小朋友,每个小朋友拿着积木的数 ...
- Block Towers (思维实现)
个人心得:这题没怎么看,题意难懂.后面比完再看的时候发现很好做但是怎么卡时间是个问题. 题意:就是有m个可以用2层积木的,n个可以用三层积木的,但是他们不允许重复所以可以无限添加. 比如 3 2 一开 ...
- 【CodeForces 626C】Block Towers
题意 给你n,m,如果 n个2的倍数和m个3的倍数,这n+m个数各不相同,那么求最大的数的最小值. 分析 方法1:枚举最大值为i,直到 i/2+i/3-i/6(不重复的2或3的倍数)≥n+m,并且要i ...
- CodeForces 626C Block Towers
构造AC的.左右两边都先不用6的倍数,然后哪边数字大那一边往回退一下,然后再比较哪边数字大.......直到结束 #include<cstdio> #include<cstring& ...
- CodeForces--626C--Block Towers (二分)
Block Towers Time Limit: 2000MS Memory Limit: 262144KB 64bit IO Format: %I64d & %I64u Submit ...
随机推荐
- ActionScript 3.0 for the Lunder Algorithm
package com.feiruo.Calendar.LunderCalendar { /* *@ClassName: package:com.feiruo.Calendar.LunderCalen ...
- 双击vbs时,默认cscript运行脚本
Dim obj_shellset obj_shell = createobject("wscript.shell")host = WScript.FullNameIf LCase( ...
- eclipse下tomcat添加部署Module,Web名称与项目名称不一致的解决方法
问题描述: 使用eclipse,因为某种原因项目名称修改后,使用tomcat进行web发布时,选择“Add and Remove Projects...”或双击打开选择Modules选项卡后点击“An ...
- 百度Ueditor
最近用到了百度Ueditor,也来写一写百度Ueditor的使用教程: 一.从官网下载百度Ueditor,http://ueditor.baidu.com/website/download.html, ...
- string.Format 格式化输出日期
string.Format("{0:d}",System.DateTime.Now) 结果为:2009-3-20 (月份位置不是03) string.Format("{0 ...
- ffmpeg - libavutil/attribute.h
在ffmpeg中,这个文件被很多其他的文件所包含.该文件中定义了一些gcc中支持的语言扩展的宏, 例如强制内联,外部内联,pure函数等.并根据是否使用了GCC,以及GCC的版本,把宏转换为 相应的编 ...
- window date type
Most string operations can use the same logic for Unicode and for Windows code pages. The only diffe ...
- handler 异步执行(进度条加载到100)
生明一个handler 对象(可重写handlerMessage 方法) 声明一个Runnable 对象,需重写run方法 按钮事件:handler对象实例的post方法调用线程. 线程的run方法开 ...
- 获取datagrid选择行
var rows = $('#dg').datagrid('getChecked'); var ids = ''; for (var i = 0; i < rows.length; i ...
- Android中ListView异步加载图片错位、重复、闪烁问题分析及解决方案
我们在使用ListView异步加载图片的时候,在快速滑动或者网络不好的情况下,会出现图片错位.重复.闪烁等问题,其实这些问题总结起来就是一个问题,我们需要对这些问题进行ListView的优化. 比如L ...