zoukankan      html  css  js  c++  java
  • 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 = 10000000 + 10;
    int n, m;
    int a[maxn];
    int b[maxn];
    int flag[maxn];
    int topa, topb;
    
    int main()
    {
        scanf("%d%d", &n, &m);
        memset(a, 0, sizeof a);
        memset(b, 0, sizeof b);
        memset(flag, 0, sizeof flag);
        int num1 = 0, num2 = 0, num;
        int nowa = 0, nowb = 0;
        for (int aa = 0, i = 2; aa < n; i = i + 2)
        {
            if (i % 6 != 0) a[i] = 1, topa = i, aa++;
            else nowa = i;
        }
        for (int aa = 0, i = 3; aa<m; i = i + 3)
        {
            if (i % 6 != 0) b[i] = 1, topb = i, aa++;
            else nowb = i;
        }
        while (1)
        {
            if (nowa == 0 && nowb == 0) break;
            if (topa>topb)
            {
                a[topa] = 0; topa--;
                while (1)
                {
                    if (b[nowa] == 0)
                    {
                        a[nowa] = 1;
                        nowa = nowa - 6;
                        while (1)
                        {
                            if (a[topa]) break;
                            topa--;
                        }
                        break;
                    }
                    nowa = nowa - 6;
                }
            }
            else
            {
                b[topb] = 0; topb--;
                while (1)
                {
                    if (a[nowb] == 0)
                    {
                        b[nowb] = 1;
                        nowb = nowb - 6;
                        while (1)
                        {
                            if (b[topb]) break;
                            topb--;
                        }
                        break;
                    }
                    nowb = nowb - 6;
                }
            }
            while (1)
            {
                if (b[nowa]) nowa = nowa - 6;
                else break;
            }
            while (1)
            {
                if (a[nowb]) nowb = nowb - 6;
                else break;
            }
        }
        printf("%d
    ", max(topa, topb));
        return 0;
    }
  • 相关阅读:
    [转]ANDROID JNI之JAVA域与c域的互操作
    android 管理Touch事件
    android gesture检测
    android 数据库操作
    android 文件保存
    【转】Android 添加系统服务
    【转】android makefile文件分析
    vlc 编译
    oracle to_date 函数
    ORACLE分页SQL语句(转载)
  • 原文地址:https://www.cnblogs.com/zufezzt/p/5203476.html
Copyright © 2011-2022 走看看