洛谷U406410 2024春晚之刘谦的魔术(附视频讲解)

题目链接icon-default.png?t=N7T8https://www.luogu.com.cn/problem/U406410

视频讲解

#include<bits/stdc++.h>
using namespace std;
bool m[15];
bool n[15];
int main()
{
    int a,b,c,d,e,i;
    cin>>a>>b>>c>>d>>e;
    if(b!=a-1)
    {
        cout<<"No";
        return 0;
    }
    else
    {
        int s1=2*a-1-c;
        int s2=2*a-1-d;
        int t1=s1-e%s1;
        int t2=s2-s2%e;
        int bj=1;
        for(i=1;i<s1;i++)
        {
            while(m[bj]!=0)
            {
                bj++;
                if(bj>s1)
                    bj=1;
            }
            bj++;
            if(bj>s1)
                bj=1;
            while(m[bj]!=0)
            {
                bj++;
                if(bj>s1)
                    bj=1;
            }
            m[bj]=1;
        }
        if(m[t1]!=0)
        {
            cout<<"No";
            return 0;
        }
        bj=1; 
        for(i=1;i<s2;i++)
        {
            while(n[bj]!=0)
            {
                bj++;
                if(bj>s2)
                    bj=1;
            }
            bj++;
            if(bj>s2)
                bj=1;
            while(n[bj]!=0)
            {
                bj++;
                if(bj>s2)
                    bj=1;
            }
            n[bj]=1;
        }
        if(n[t2]!=0)
        {
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
    return 0;
}

相关推荐

  1. 龙年魔术模拟

    2024-02-14 10:04:01       49 阅读
  2. 魔术解析Python

    2024-02-14 10:04:01       57 阅读
  3. 用Python实现魔术

    2024-02-14 10:04:01       48 阅读
  4. 2024魔术C++实现

    2024-02-14 10:04:01       59 阅读
  5. Python实现2024魔术

    2024-02-14 10:04:01       45 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-02-14 10:04:01       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-02-14 10:04:01       100 阅读
  3. 在Django里面运行非项目文件

    2024-02-14 10:04:01       82 阅读
  4. Python语言-面向对象

    2024-02-14 10:04:01       91 阅读

热门阅读

  1. 【生产实测有效】Linux磁盘清理常用命令

    2024-02-14 10:04:01       48 阅读
  2. C语言静态库深入剖析

    2024-02-14 10:04:01       48 阅读
  3. Python Flask Web 框架学习笔记+完整项目

    2024-02-14 10:04:01       46 阅读
  4. 2024.2.6

    2024.2.6

    2024-02-14 10:04:01      43 阅读
  5. STM32面试相关问题

    2024-02-14 10:04:01       46 阅读
  6. Node.js开发-fs模块

    2024-02-14 10:04:01       46 阅读
  7. Node.js基础---path路径模块

    2024-02-14 10:04:01       52 阅读
  8. MongoDB聚合:$graphLookup

    2024-02-14 10:04:01       41 阅读
  9. 【力扣每日一题】力扣987二叉树的垂序遍历

    2024-02-14 10:04:01       66 阅读
  10. 力扣-28. 找出字符串中第一个匹配项的下标

    2024-02-14 10:04:01       37 阅读