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的倍数积木的小朋友,每个小朋友拿着积木的数 ...
随机推荐
- Zookeeper: configuring on centos7
thispassage is referenced, appreciated. ZooKeeper installation: Download from this site Install java ...
- 最短路<dijk>
题意: 有n个城市,有m条路,给出每条路的出发和结束的城市及长度,求从第一个城市到最后一个城市的最短路.按格式输出. power oj 2443 题解: 标准dijk算法. #include<c ...
- 为Android系统内置C可执行程序测试Linux内核驱动程序
在前一篇文章中,我们介绍了如何在Ubuntu上为Android系统编写Linux内核驱动程序.在这个名为hello的Linux内核驱动程序中, 创建三个不同的文件节点来供用户空间访问,分别是传统的设备 ...
- CentOS下编译安装Apache(httpd)
官网下载最新版本的apache, apr, apr-util http://httpd.apache.org/download.cgi#apache24 http://apr.apache.org/d ...
- CodeForces 678B The Same Calendar
暴力.一年一年判断过去.如果某一年与输入的年份闰年性质相同,并且1月1日是星期几相同,那么输出. #include<cstdio> #include<cstring> #inc ...
- C++头文件#include<bits/stdc++.h>
一句话的事,直截了当——#include<bits/stdc++.h>包含C++的所有头文件 参考网站(点击):http://www.tuicool.com/articles/m6neUj ...
- 项目中常用js方法整理common.js
抽空把项目中常用js方法整理成了common.js,都是网上搜集而来的,大家一起分享吧. var h = {}; h.get = function (url, data, ok, error) { $ ...
- 关于tomcat配置MyEclipse项目的配置代码
例如:<Context path="/shis" docBase="E:\Genuitec\Workspaces\MyEclipse 8.6\zwfw_platfo ...
- jQuery常用及基础知识总结(一)
Attribute: $(”p”).addClass(css中定义的样式类型); 给某个元素添加样式$(”img”).attr({src:”test.jpg”,alt:”test Image”}); ...
- HTML5 学习01
HTML的英语意思是:Hypertext Marked Language,即超文本标记语言,是一种用来制作超文本文档的简单标记语言. 所谓超文本,是因为它可以加入图片.声音.动画.影视等内容,事实上每 ...