C. Lieges of Legendre

题意:给n,m表示有n个为2的倍数,m个为3的倍数;问这n+m个数不重复时的最大值 最小为多少?

数据:(0 ≤ n, m ≤ 1 000 000, n + m > 0)
ps:很水的题,主要是策略;

思路:由于里面每隔6就会重复一次,不好直接模拟,并且模拟的效率很低,那就二分吧!二分即上界为2单独的最大倍数与3单独时的最大倍数之和,下界为前面二者的max;之后利用判断是否mid/2 >= n && mid/3 >= m && mid/2 + mid/3 - mid/6 >= n + m 即可二分;这样running 就是log(n)了;注意最后还要判断ans是否为2|3的积即可;

#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,m;
scanf("%d%d",&n,&m);
int l = max(n*,m*),r = n* + m*,ans = ;
while(l <= r){
int mid = l + r >> ;
if(mid/ >= n && mid/ >= m && mid/ + mid/ - mid/ >= n + m) ans = mid,r = mid - ;
else l = mid + ;
}
if(ans% != && ans% != ) ans++;
printf("%d",ans);
return ;
}

codeforces 8VC Venture Cup 2016 - Elimination Round C. Lieges of Legendre的更多相关文章

  1. Codeforces 8VC Venture Cup 2016 - Elimination Round F. Group Projects 差分DP*****

    F. Group Projects   There are n students in a class working on group projects. The students will div ...

  2. 8VC Venture Cup 2016 - Elimination Round D. Jerry's Protest 暴力

    D. Jerry's Protest 题目连接: http://www.codeforces.com/contest/626/problem/D Description Andrew and Jerr ...

  3. 8VC Venture Cup 2016 - Elimination Round (C. Block Towers)

    题目链接:http://codeforces.com/contest/626/problem/C 题意就是给你n个分别拿着2的倍数积木的小朋友和m个分别拿着3的倍数积木的小朋友,每个小朋友拿着积木的数 ...

  4. 8VC Venture Cup 2016 - Elimination Round G. Raffles 线段树

    G. Raffles 题目连接: http://www.codeforces.com/contest/626/problem/G Description Johnny is at a carnival ...

  5. 8VC Venture Cup 2016 - Elimination Round F. Group Projects dp

    F. Group Projects 题目连接: http://www.codeforces.com/contest/626/problem/F Description There are n stud ...

  6. 8VC Venture Cup 2016 - Elimination Round E. Simple Skewness 暴力+二分

    E. Simple Skewness 题目连接: http://www.codeforces.com/contest/626/problem/E Description Define the simp ...

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

  8. 8VC Venture Cup 2016 - Elimination Round B. Cards 瞎搞

    B. Cards 题目连接: http://www.codeforces.com/contest/626/problem/B Description Catherine has a deck of n ...

  9. 8VC Venture Cup 2016 - Elimination Round A. Robot Sequence 暴力

    A. Robot Sequence 题目连接: http://www.codeforces.com/contest/626/problem/A Description Calvin the robot ...

随机推荐

  1. android 开源 OCR 项目 及手写识别

    http://blog.csdn.net/archfree/article/details/6023676 1)一个为Android平台,将识别由手机的相机拍摄的图像文本应用程序. http://co ...

  2. Google实习面试归来

    咱们寝室共有两个人收到面试通知,我和另一哥们G.      今天早上8:30起了个大早,洗漱完毕,简历复印完毕,就和G骑车到达了世贸中   心酒店那儿.真不愧是世贸中心啊,装修就是华丽,连看门的都是印 ...

  3. C++第四章循环

    学习时候的点: 1.用户来控制是否继续进行的模板: char goonLoop=’y’; while(goonLoop==’y’){ //logic cout<<”输入y 来继续当前逻辑, ...

  4. CSS表格固定列宽

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  5. js如何实现一定时间后去执行一个函数

    js如何实现一定时间后去执行一个函数:在实际需要中可能需要规定在指定的时间之后再去执行一个函数以达成期望的目的,这也就是一个定时器效果,恰好在js中就已经给定了这样的一个函数setTimeout(), ...

  6. ###学习《C++ Primer》- 5

    点击查看Evernote原文. // @author: gr // @date: 2014-10-20 // @email: forgerui@gmail.com Part 5: 动态内存(第12章) ...

  7. 电脑中java环境的搭建

  8. leetcode之Rectangle Area

    Find the total area covered by two rectilinear rectangles in a 2D plane. Each rectangle is defined b ...

  9. unity访问php

    长连接,弱联网.不好意思,这俩不是一个意思. 反过来说,短连接,强联网,是不是有点别扭呢. 你可以不会php,甚至你可以不知道php是干什么的. 百度php安装环境,自行搭建好环境,顺便测试一下.(下 ...

  10. (转)Quartz.NET管理类

    最近做项目设计到Quartz.NET,写了一个Quartz.NET管理类,在此记录下. public class QuartzManager<T> where T : class,IJob ...