构造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的更多相关文章

  1. Codeforces 626C Block Towers(二分)

    C. Block Towers time limit per test:2 seconds memory limit per test:256 megabytes input:standard inp ...

  2. Codeforces 626C Block Towers「贪心」「二分」「数学规律」

    题意: 一堆人用方块盖塔,有n个人每次只能加两块方块,有m个人每次只能加三块方块.要求每个人盖的塔的高度都不一样,保证所用方块数最少,求最高的塔的高度. 0<=n+m  0<=n,m< ...

  3. 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 ...

  4. codeforce626C.Block Towers(二分)

    C. Block Towers time limit per test 2 seconds memory limit per test 256 megabytes input standard inp ...

  5. Codeforces 626C

                                                                                                        ...

  6. CodeForces - 327D Block Tower

    D. Block Tower time limit per test 2 seconds memory limit per test 256 megabytes input standard inpu ...

  7. 【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 ...

  8. (二分)Block Towers(cf626)

    http://www.codeforces.com/contest/626/problem/C 题意是有一群小朋友在堆房子,现在有n个小孩每次可以放两个积木,m个小孩,每次可以放3个积木,最后每个小孩 ...

  9. 8VC Venture Cup 2016 - Elimination Round (C. Block Towers)

    题目链接:http://codeforces.com/contest/626/problem/C 题意就是给你n个分别拿着2的倍数积木的小朋友和m个分别拿着3的倍数积木的小朋友,每个小朋友拿着积木的数 ...

随机推荐

  1. js设置全局变量ajax中赋值

    js设置全局变量,在ajax中给予赋值赋值不上问题解决方案 方案一. //在全局或某个需要的函数内设置Ajax异步为false,也就是同步. $.ajaxSetup({async : false}); ...

  2. Interview with Oleg

    Interview with Oleg time limit per test 1 second memory limit per test 256 megabytes input standard ...

  3. iOS 开发之照片框架详解之二 —— PhotoKit 详解(下)

    本文链接:http://kayosite.com/ios-development-and-detail-of-photo-framework-part-three.html 这里接着前文<iOS ...

  4. HDU-1232--畅通工程(最小生成树)

    Problem Description 某省调查城镇交通状况,得到现有城镇道路统计表,表中列出了每条道路直接连通的城镇.省政府"畅通工程"的目标是使全省任何两个城镇间都可以实现交通 ...

  5. GenericApp SampleApp SimpleAp的区别

    SampleApp3.2 Zigbee2007 协议栈实验例程表演说明C:\Texas Instruments\ZStack-2.0.0-1.2.0\Projects\zstack\Samples\S ...

  6. CenOS配置VSFTP服务器

    1 Linux FTP服务器分类: wu-ftp proftp=profession ftp vsftp=very security ftp 2 安装vsftp yum install vsftp 3 ...

  7. Swift学习(1)

    swif(1) println("Hello, world") 输出结果: Hello, world swift使用let来声明常量,使用var来声明变量 //变量 var myV ...

  8. ListView random IndexOutOfBoundsException on Froyo

    http://stackoverflow.com/questions/8431342/listview-random-indexoutofboundsexception-on-froyo 今天遇到个 ...

  9. USACO Section 1.3 Wormholes 解题报告

    题目 题目描述 在一个二维平面上有N个点,这N个点是(N/2)个虫洞的端点,虫洞的特点就是,你以什么状态从某个端点进去,就一定会以什么状态从另一端的端点出来.现在有一头牛总是沿着与X轴正方向平行的直线 ...

  10. drawable文件夹详解

    QVGA使用ldpi,虽然有不同尺寸,但都是120dpi左右:HVGA同理:如下图: -finger    用于触摸屏的设备 -hdpi    近似于240dpi的高级显示密度的屏幕 -mdpi    ...