CodeForces 626C Block Towers
构造AC的。左右两边都先不用6的倍数,然后哪边数字大那一边往回退一下,然后再比较哪边数字大.......直到结束
#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<iostream>
using namespace std; const int maxn = + ;
int n, m;
int a[maxn];
int b[maxn];
int flag[maxn];
int topa, topb; int main()
{
scanf("%d%d", &n, &m);
memset(a, , sizeof a);
memset(b, , sizeof b);
memset(flag, , sizeof flag);
int num1 = , num2 = , num;
int nowa = , nowb = ;
for (int aa = , i = ; aa < n; i = i + )
{
if (i % != ) a[i] = , topa = i, aa++;
else nowa = i;
}
for (int aa = , i = ; aa<m; i = i + )
{
if (i % != ) b[i] = , topb = i, aa++;
else nowb = i;
}
while ()
{
if (nowa == && nowb == ) break;
if (topa>topb)
{
a[topa] = ; topa--;
while ()
{
if (b[nowa] == )
{
a[nowa] = ;
nowa = nowa - ;
while ()
{
if (a[topa]) break;
topa--;
}
break;
}
nowa = nowa - ;
}
}
else
{
b[topb] = ; topb--;
while ()
{
if (a[nowb] == )
{
b[nowb] = ;
nowb = nowb - ;
while ()
{
if (b[topb]) break;
topb--;
}
break;
}
nowb = nowb - ;
}
}
while ()
{
if (b[nowa]) nowa = nowa - ;
else break;
}
while ()
{
if (a[nowb]) nowb = nowb - ;
else break;
}
}
printf("%d\n", max(topa, topb));
return ;
}
CodeForces 626C Block Towers的更多相关文章
- Codeforces 626C Block Towers(二分)
C. Block Towers time limit per test:2 seconds memory limit per test:256 megabytes input:standard inp ...
- Codeforces 626C Block Towers「贪心」「二分」「数学规律」
题意: 一堆人用方块盖塔,有n个人每次只能加两块方块,有m个人每次只能加三块方块.要求每个人盖的塔的高度都不一样,保证所用方块数最少,求最高的塔的高度. 0<=n+m 0<=n,m< ...
- 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 ...
- codeforce626C.Block Towers(二分)
C. Block Towers time limit per test 2 seconds memory limit per test 256 megabytes input standard inp ...
- Codeforces 626C
...
- CodeForces - 327D Block Tower
D. Block Tower time limit per test 2 seconds memory limit per test 256 megabytes input standard inpu ...
- 【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 ...
- (二分)Block Towers(cf626)
http://www.codeforces.com/contest/626/problem/C 题意是有一群小朋友在堆房子,现在有n个小孩每次可以放两个积木,m个小孩,每次可以放3个积木,最后每个小孩 ...
- 8VC Venture Cup 2016 - Elimination Round (C. Block Towers)
题目链接:http://codeforces.com/contest/626/problem/C 题意就是给你n个分别拿着2的倍数积木的小朋友和m个分别拿着3的倍数积木的小朋友,每个小朋友拿着积木的数 ...
随机推荐
- jsp环境搭建(Windows)
1.软件准备 JDK 最新版jdk-8u45-windows-x64.exe tomcat 最新版32-bit/64-bit Windows Service Installer Eclipse IDE ...
- 什么是dtd文件,为什么需要
DTD为英文Document Type Definition,中文意思为“文档类定义”.DTD肩负着两重任务:一方面它帮助你编写合法的代码,另一方面它让浏览器正确地显示器代码.也许你会问它们居然有这样 ...
- xcconfig 文件配置文件 问题
与公司 QA 聊天,已不止一次被吐槽说移动端从开发环境转到生产环境时,还要靠修改代码来配置对应的环境参数.她认为,从 App 转测试之后,就不应该再修改代码,可以把所有的环境配置都整合到配置文件中,这 ...
- Break on _NSLockError() to debug.
*** -[NSCondition dealloc]: condition (<NSCondition: 0x1039a450> '(null)') deallocated while s ...
- 最短路径算法——Dijkstra算法
在路由选择算法中都要用到求最短路径算法.最出名的求最短路径算法有两个,即Bellman-Ford算法和Dijkstra算法.这两种算法的思路不同,但得出的结果是相同的. 下面只介绍Dijkstra算法 ...
- Dom++完美版得到元素到html的距离6/4/21
function getTop(obj) { var pos={left:0,top:0}; while(obj) { pos.left+=obj.offsetLeft; pos.top+=obj.o ...
- PowerDesigner中逆向工程将数据库中comment赋值到name
'------------------------------------------------------------ ' '脚本功能: ' PowerDesigner中逆向工程完成后,将数据库中 ...
- hdu_5555_Immortality of Frog(状压DP)
题目连接:hdu_5555_Immortality of Frog 题意: 给你一个NxN的网格,第N行的每一列都有个青蛙,这些青蛙只会往上走,上帝会在每个膜中放一个长生不老的药,一共有N个膜,每个膜 ...
- Linux 安装 Redis 服务
下载地址 http://download.redis.io/releases/redis-3.2.0.tar.gz 官网下载地址 http://redis.io/download 1.下载安装包 cd ...
- Mac linux 安装memcached服务 用法
今天在Mac上安装memcached服务的时候 由于安装memcached之前需要安装libevent依赖包 所以使用brew install libevent 安装过程中报错 Warning: Yo ...