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. FactoryBean的使用--转

    一般情况下,Spring通过反射机制利用bean的class属性指定实现类来实例化bean .在某些情况下,实例化bean过程比较复杂,如果按照传统的方式,则需要在<bean>中提供大量的 ...

  2. linux vi 撤销重做于前进后退--转

    在vi中按u可以撤销一次操作 u   撤销上一步的操作Ctrl+r 恢复上一步被撤销的操作 注意:如果你输入“u”两次,你的文本恢复原样,那应该是你的Vim被配置在Vi兼容模式了.重做如果你撤销得太多 ...

  3. Objective-C中系统宏的用法总结

    先说一下本文中会提到的内容:##,__VA_ARGS__, __FILE__, __LINE__ , __FUNCTION__等 宏变量: 先举一个例子,会用到上面这些宏: #define mypri ...

  4. LogstashL reference 重要章节

    配置文件结构说明 https://www.elastic.co/guide/en/logstash/current/configuration-file-structure.html Event相关配 ...

  5. 使用VS建立Web网站及IIS

    一:网站运行的一般原理: 1.所有WEB程序运行都需要一个东西:Web服务器软件. 2. 网站分为动态页面和静态页面 3. web服务器软件的作用:接收请求,响应请求. 被动——无请求则无响应. Ja ...

  6. Ubuntu 修改时间

    输入"date",显示的是: Tue Jan :: UTC 输入"date -R" 显示的是: Tue, Jan :: + 和北京时间相差了8个小时. 1.选择 ...

  7. Ubuntu lnmp安装记录

    参考了: Ubuntu 14.04 LTS 安装 LNMP Nginx\PHP5 (PHP-FPM)\MySQL 在访问 info.php的时候,我显示的是502错误.后面我参考了: Ubuntu15 ...

  8. MongoDB自定义函数部分 定义及引用

    1. //定义一个Sum的函数 db.system.js.save({_id:"Sum", value:function(key,values) { ; ;i <values ...

  9. js运动

    一.offsetWidth / offsetHeight 获取整个块的宽度/高度,包括border 二.clientWidth / clientHeight 获取块的宽度/高度,不包括border 三 ...

  10. foo,bar,baz

    https://en.wikipedia.org/wiki/Foobar 原文: The terms foobar, foo, bar, baz and qux are sometimes used ...