codeforces 8VC Venture Cup 2016 - Elimination Round 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的更多相关文章
- 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 ...
- 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 ...
- 8VC Venture Cup 2016 - Elimination Round (C. Block Towers)
题目链接:http://codeforces.com/contest/626/problem/C 题意就是给你n个分别拿着2的倍数积木的小朋友和m个分别拿着3的倍数积木的小朋友,每个小朋友拿着积木的数 ...
- 8VC Venture Cup 2016 - Elimination Round G. Raffles 线段树
G. Raffles 题目连接: http://www.codeforces.com/contest/626/problem/G Description Johnny is at a carnival ...
- 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 ...
- 8VC Venture Cup 2016 - Elimination Round E. Simple Skewness 暴力+二分
E. Simple Skewness 题目连接: http://www.codeforces.com/contest/626/problem/E Description Define the simp ...
- 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 ...
- 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 ...
- 8VC Venture Cup 2016 - Elimination Round A. Robot Sequence 暴力
A. Robot Sequence 题目连接: http://www.codeforces.com/contest/626/problem/A Description Calvin the robot ...
随机推荐
- REM 注释
REM 是DOS批处理和VB的注释语句.所谓注释语句,就是程序的执行时会跳过该行(不管它后面写的什么),它为编程者起到一个批注的功能,以达到好的可读性以便于交流以及起到备忘作用. 在批处理命令中如果不 ...
- Apache配置虚拟目录,以及各种操作
apache配置虚拟目录: 打开并创建虚拟目录的步骤如下: # Virtual hosts # Include conf/extra/httpd-vhosts.conf 去掉conf/http.con ...
- 加密解密知识 php非对称加密
function test1(){ $config = array( "digest_alg" => "sha1", "private_key_ ...
- Android_SeekBar
xml: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:too ...
- Python中作用域的特别之处
def a(): a = [] def aappend(): a.append(1) aappend() print a def b(): b = 1 def bchange(): b += 1 # ...
- mapping 详解2(field datatypes)
基本类型 1. 字符串 字符串类型被分为两种情况:full-text 和 keywords. full-text 表示字段内容会被分析,而 keywords 表示字段值只能作为一个精确值查询. 参数: ...
- Android开发了解——AIDL
AIDL:Android Interface Definition Language,即Android接口定义语言. 什么是AIDL Android系统中的进程之间不能共享内存,因此,需要提供一些机制 ...
- jemter接口测试之---接口测试的一些约定
一.接口规范 1.前端请求接口 请求数据格式:appType =1&args ={json}&session =xxx×tamp =now&sign =x ...
- 关于sharepoint 2010无法显示用户中文名的解决方法和详细剖析
相信这个问题许多做sharepoint的朋友都曾经遇到过,就是本来很正常的中文用户名莫名其妙的变成了“域名\账号”,我本人也遇到过好多次,每次都是百度谷歌一下草草解决问题,始终也没真正去弄明白是怎么回 ...
- transition和animation动画简介
本文介绍CSS动画的两大组成部分:transition和animation.我不打算给出每一条属性的详尽介绍,那样可以写一本书.这篇文章只是一个简介,帮助初学者了解全貌,同时又是一个快速指南,当你想不 ...