zoukankan      html  css  js  c++  java
  • Codeforces Round #562 (Div. 2) A.Circle Metro

    链接:https://codeforces.com/contest/1169/problem/A

    题意:

    The circle line of the Roflanpolis subway has nn stations.

    There are two parallel routes in the subway. The first one visits stations in order 12n121→2→…→n→1→2→… (so the next stop after station xx is equal to (x+1)(x+1) if x<nx<n and 11 otherwise). The second route visits stations in order n(n1)1n(n1)n→(n−1)→…→1→n→(n−1)→… (so the next stop after station xx is equal to (x1)(x−1) if x>1x>1 and nn otherwise). All trains depart their stations simultaneously, and it takes exactly 11 minute to arrive at the next station.

    Two toads live in this city, their names are Daniel and Vlad.

    Daniel is currently in a train of the first route at station aa and will exit the subway when his train reaches station xx.

    Coincidentally, Vlad is currently in a train of the second route at station bb and he will exit the subway when his train reaches station yy.

    Surprisingly, all numbers a,x,b,ya,x,b,y are distinct.

    Toad Ilya asks you to check if Daniel and Vlad will ever be at the same station at the same time during their journey. In other words, check if there is a moment when their trains stop at the same station. Note that this includes the moments when Daniel or Vlad enter or leave the subway.

    思路:

    暴力

    代码:

    #include <bits/stdc++.h>
    
    using namespace std;
    
    typedef long long LL;
    const int MAXN = 1e5 + 10;
    const int MOD = 1e9 + 7;
    int n, m, k, t;
    int p, q, u, v;
    int x, y, z, w;
    int a, b;
    
    int main()
    {
        cin >> n >> a >> x >> b >> y;
        bool flag = false;
        int len = 2*n;
        while(len--)
        {
            a++;
            if (a > n)
                a = 1;
            b--;
            if (b < 1)
                b = n;
            if (a == b)
                flag = true;
            if (a == x || b == y)
                break;
        }
        if (flag)
            cout << "YES" << endl;
        else
            cout << "NO" << endl;
    
        return 0;
    }
    

      

  • 相关阅读:
    用GDB调试程序(一)
    关于“鸡脚神”的看法
    Oracle 经典SQL 专为笔试准备
    怎样设计接口?
    myeclipse6.0下载及注冊码
    VB连接Mysql数据库
    开源html5_kiwijs_helloworld
    server宕机监控、检測、报警程序(139绑定手机短信报警)monitor_down.sh
    js实现自己定义鼠标右键-------Day45
    C/C++程序猿必须熟练应用的开源项目
  • 原文地址:https://www.cnblogs.com/YDDDD/p/10930192.html
Copyright © 2011-2022 走看看