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 ...
随机推荐
- eoe推荐的优秀博客
<a href="http://my.eoe.cn/huodong/archive/5430.html">http://my.eoe.cn/huodong/archiv ...
- How-to Dump Keys from Memcache--reference
Submitted by Lars Windolf on 19. October 2012 - 21:53 http://lzone.de/dump%20memcache%20keys You spe ...
- GCD多线程
GCD本质线程自动管理指令包 GCD优点: 1.GCD 本身自带有线程锁的效果,能通过推迟昂贵计算任务并在后台运行它们来改善应用的响应性能. 2.GCD 提供了更易于使用的并发模型(效果方面类似于对锁 ...
- Java基础知识强化之网络编程笔记10:TCP之客户端读取文本文件服务器控制台输出
1. TCP之客户端读取文本文件服务器控制台输出 (1)客户端:(发送数据到服务端) package cn.itcast_10; import java.io.BufferedReader; impo ...
- APP运营干货分享
从移动互联网市场总监岗位出发,从几个方面来阐述移动互联网部门如何制定一份运营推广策划案,至于关于移动互联网,移动电商是大趋势这些虚的.空泛的文字,不展开说了. 一.竞品分析 1.选择竞品,做好定位(选 ...
- 巧用Red Gate SQL Compare破解加密了的存储过程和函数
最近项目中遇到了一个遗留系统的存储过程和函数被加密了,网上找了半天,解决办法倒是有,但需要写一大堆脚本, 怕影响原系统的运行,就说先同步到其他服务器上去破解.没想到,打开Sql Compare一比 ...
- 用happen-before规则重新审视DCL(转载)
编写Java多线程程序一直以来都是一件十分困难的事,多线程程序的bug很难测试,DCL(Double Check Lock)就是一个典型,因此对多线程安全的理论分析就显得十分重要,当然这决不是说对多线 ...
- idl生成.h .c文件
1.从命令行执行 设置INCLUDE.LIB等,可先运行vsvars32.bat(C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\ ...
- ACM——快速排序法
快速排序 时间限制(普通/Java):1000MS/3000MS 运行内存限制:65536KByte总提交:653 测试通过:297 描述 给定输入排序元素数目 ...
- sql 更新重复数据只取一条记录
select s.* from ( select *, row_number() over (partition by PersonnelAccount order BY Personnel ...