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的倍数积木的小朋友,每个小朋友拿着积木的数 ...
随机推荐
- 【最短路】 poj 2387
#include <iostream> #include <stdlib.h> #include <limits.h> #include <string.h& ...
- URL特殊字符需转义
URL特殊字符需转义 1.空格换成加号(+) 2.正斜杠(/)分隔目录和子目录 3.问号(?)分隔URL和查询 4.百分号(%)制定特殊字符 5.#号指定书签 6.&号分隔参数 转义字符的原因 ...
- scrollview上面的图片不上下滑动
self.automaticallyAdjustsScrollViewInsets= NO;
- 35W行数据的文本文件,每500行添加4个换行符。代码实现思路
- 使用Theos做一个简单的Mobile Substrate Tweak
01 January 2014 Mobile Substrate和Theos Mobile Substrate是Cydia的作者Jay Freeman (@saurik)的另外一个牛X的作品,也叫Cy ...
- VideoView的视频播放
//-------------onCreate方法中----------------------- VideoView video_view = (VideoView) findViewById(R. ...
- C 汇编代码 函数调用指令和栈平衡
1. CALL指令: CALL指令可不是如唤指令,而是子程序调用指令.那么汇编语言中的子程序是什么呢?子程序能被其它程序调用,在实现某种功能后能自动返回到调用程序去的程序.其最后一条指令一定是返回指令 ...
- IDL 遍历 XML文档示例
IDL解析XML文档同样也有2种方法:DOM和SAX方式:两种方法在IDL自带的帮助里面有详细介绍,可以去查看. IDL 源码PRO sample_recurse, oNode, indent COM ...
- 设置批量商品优惠、如何修改ZenCart产品显示图片的大小
利用下面的方法,可以实现: 买一送一.买一件第二件5折.买三件优惠10%等功能. 管理页面 - 商品管理 - 价格管理 - (选择商品) - 编辑 - 添加空白折扣. 应用上面的办法,能够完成:买一送 ...
- Chapter 1 First Sight——10
Instead, I was ivory-skinned, without even the excuse of blue eyes or red hair, despite the constant ...