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 1→2→…→n→1→2→…1→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→(n−1)→…→1→n→(n−1)→…n→(n−1)→…→1→n→(n−1)→… (so the next stop after station xx is equal to (x−1)(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;
}
Codeforces Round #562 (Div. 2) A.Circle Metro的更多相关文章
- [Done] Codeforces Round #562 (Div. 2) 题解
A - Circle Metro 模拟几百步就可以了. B - Pairs 爆搜一下,时间复杂度大概是 $O(4 * n)$ Code: 56306723 C - Increasing by Modu ...
- Codeforces Round #562 (Div. 2) C. Increasing by Modulo
链接:https://codeforces.com/contest/1169/problem/C 题意: Toad Zitz has an array of integers, each intege ...
- Codeforces Round #562 (Div. 2) B. Pairs
链接:https://codeforces.com/contest/1169/problem/B 题意: Toad Ivan has mm pairs of integers, each intege ...
- Codeforces Round #418 (Div. 2) D. An overnight dance in discotheque
Codeforces Round #418 (Div. 2) D. An overnight dance in discotheque 题意: 给\(n(n <= 1000)\)个圆,圆与圆之间 ...
- Codeforces Round #579 (Div. 3)
Codeforces Round #579 (Div. 3) 传送门 A. Circle of Students 这题我是直接把正序.逆序的两种放在数组里面直接判断. Code #include &l ...
- Codeforces Round #564 (Div. 1)
Codeforces Round #564 (Div. 1) A Nauuo and Cards 首先如果牌库中最后的牌是\(1,2,\cdots, k\),那么就模拟一下能不能每次打出第\(k+i\ ...
- Codeforces Round #366 (Div. 2) ABC
Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...
- Codeforces Round #354 (Div. 2) ABCD
Codeforces Round #354 (Div. 2) Problems # Name A Nicholas and Permutation standard input/out ...
- Codeforces Round #368 (Div. 2)
直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...
随机推荐
- HDU 3853 LOOPS:期望dp【网格型】
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3853 题意: 有一个n*m的网格. 给出在每个格子时:留在原地.向右走一格,向下走一格的概率. 每走一 ...
- 用js实现图片(小球)在屏幕上上下左右移动
<html> <head> <title>Document</title> </head> <body style="bac ...
- POJ 2497 Strategies
题意:有三个人,Bill, Steve and Linus,他们参加竞赛,给出竞赛的题目和比赛时间,然后给出每道题需要的时间(他们解同一道题花的时间相同),然后他们有不同的策略来做题.每道题的得分为当 ...
- poj1733 Parity game[带权并查集or扩展域]
地址 连通性判定问题.(具体参考lyd并查集专题该题的转化方法,反正我菜我没想出来).转化后就是一个经典的并查集问题了. 带权:要求两点奇偶性不同,即连边权为1,否则为0,压缩路径时不断异或,可以通过 ...
- 洛谷 P2919 [USACO08NOV]守护农场Guarding the Farm
题目描述 The farm has many hills upon which Farmer John would like to place guards to ensure the safety ...
- 【Python】python2.7 安装配置OpenCV2
环境:Ubuntu16.04 anaconda Python2.7 opencv2.4.13 安装opencv后 import cv2 遇到错误信息: No module named cv2 安装op ...
- Redo Gap 处理与优化
理论背景 当redo data 传送发生中断时就会产生redo gap.当redo 传送恢复正常以后,redo transport service 会自动检测redo gap并发送缺失的redo 到d ...
- ZigBee自组网地址分配与路由协议概述
1. ZigBee简介 ZigBee是基于IEEE802.15.4标准的低功耗局域网协议.根据国际标准规定,ZigBee技术是一种短距离.低功耗的无线通信技术. ZigBee协议从下到上分别为物理层( ...
- ZigBee简介
前言 目前,中国大力推广的物联网是zigbee 应用的主战场,物联网通过智能感知.识别技术与普适计算(我还特意申请了个域名psjs.vip).泛在网络的融合应用,被称为继计算机.互联网之后世界信息产业 ...
- Ubuntu 获得超级用户权限
sudo passwd root 首先要先输入当前用户的密码,再在"输入新的UNIX密码"后面输入你想要设置的 root 密码即可,然后就可以切换到 super user 了: $ ...