【CodeForces - 1200C】Round Corridor (数论gcd)
Round Corridor
Descriptions
Amugae位于一个非常大的圆形走廊中。走廊由两个区域组成。内部区域等于nñ扇区,外部区域等于m米部门。在相同区域(内部或外部)的每对扇区之间存在壁,但在内部区域和外部区域之间没有壁。墙壁始终存在于12点钟位置。
内部区域的扇区被表示为(1,1),(1,2),...,(1,Ñ)(1,1),(1,2),…,(1,ñ)顺时针方向。外部区域的扇区被表示为(2,1),(2,2),...,(2,米)(2,1),(2,2),…,(2,米)以相同的方式。有关清楚的理解,请参阅上面的示例图像。
Amugae想知道他是否可以从一个部门转移到另一个部门。他有q个问题。
对于每个问题,检查他是否可以在两个给定的扇区之间移动。
Input
第一行包含三个整数n,m和q(1≤n,m≤1018 ,1≤n,m≤1018,1≤q≤104,1≤q≤104) - 内部区域的扇区数,扇区数在外部区域和问题的数量。 每个下一个q行包含四个整数sx,sy,ex,ey。 Amague想要知道是否有可能从扇区(sx,sy)(sx,sy)转移到扇区(ex,ey)(例如,ey)。
Output
对于每个问题,如果Amugae可以从(sx,sy)(sx,sy)移动到(ex,ey)(ex,ey),则打印“YES”,否则打印“NO”。 您可以在任何情况下(上部或下部)打印每个字母
Example
Input4 6 3
1 1 2 3
2 6 1 2
2 6 2 4
OutputYES
NO
YES
Note
示例显示在声明中的图片上。
题目链接
https://vjudge.net/problem/CodeForces-1200C
AC代码
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <sstream>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define Mod 1000000007
#define eps 1e-6
#define ll long long
#define INF 0x3f3f3f3f
#define MEM(x,y) memset(x,y,sizeof(x))
#define Maxn 100005
using namespace std;
ll n,m,q;
ll sx,sy,ex,ey;
int main()
{
cin>>n>>m>>q;
ll g=__gcd(n,m);
n/=g;
m/=g;
while(q--)
{
cin>>sx>>sy>>ex>>ey;
sy--,ey--;
ll t1,t2;
if(sx==)
t1=n;
if(sx==)
t1=m;
if(ex==)
t2=n;
if(ex==)
t2=m;
if((sy/t1)==(ey/t2))
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
}
return ;
}
【CodeForces - 1200C】Round Corridor (数论gcd)的更多相关文章
- [gcd,灵感] Codeforces 1200C Round Corridor
题目:https://codeforces.com/contest/1200/problem/C C. Round Corridor time limit per test 1 second memo ...
- Codeforces Beta Round #17 D. Notepad (数论 + 广义欧拉定理降幂)
Codeforces Beta Round #17 题目链接:点击我打开题目链接 大概题意: 给你 \(b\),\(n\),\(c\). 让你求:\((b)^{n-1}*(b-1)\%c\). \(2 ...
- CodeForces Global Round 1
CodeForces Global Round 1 CF新的比赛呢(虽然没啥区别)!这种报名的人多的比赛涨分是真的快.... 所以就写下题解吧. A. Parity 太简单了,随便模拟一下就完了. B ...
- Codeforces Beta Round #73 (Div. 2 Only)
Codeforces Beta Round #73 (Div. 2 Only) http://codeforces.com/contest/88 A 模拟 #include<bits/stdc+ ...
- Codeforces Beta Round #67 (Div. 2)
Codeforces Beta Round #67 (Div. 2) http://codeforces.com/contest/75 A #include<bits/stdc++.h> ...
- Codeforces Beta Round #16 (Div. 2 Only)
Codeforces Beta Round #16 (Div. 2 Only) http://codeforces.com/contest/16 A 水题 #include<bits/stdc+ ...
- Codeforces Beta Round #9 (Div. 2 Only)
Codeforces Beta Round #9 (Div. 2 Only) http://codeforces.com/contest/9 A gcd水题 #include<bits/stdc ...
- Codeforces Global Round 1 (A-E题解)
Codeforces Global Round 1 题目链接:https://codeforces.com/contest/1110 A. Parity 题意: 给出{ak},b,k,判断a1*b^( ...
- [CodeForces - 1225C]p-binary 【数论】【二进制】
[CodeForces - 1225C]p-binary [数论][二进制] 标签: 题解 codeforces题解 数论 题目描述 Time limit 2000 ms Memory limit 5 ...
随机推荐
- Android使用WebView加载H5页面播放视频音频,退出后还在播放问题解决
Android中经常会使用到WebView来加载H5的页面,如果H5页面中有音频或者视频的播放时,还没播放完就退出界面,这个时候会发现音频或者视频还在后台播放,这就有点一脸懵逼了,下面是解决方案: 方 ...
- Spring Boot 邮件发送的 5 种姿势!
邮件发送其实是一个非常常见的需求,用户注册,找回密码等地方,都会用到,使用 JavaSE 代码发送邮件,步骤还是挺繁琐的,Spring Boot 中对于邮件发送,提供了相关的自动化配置类,使得邮件发送 ...
- akka 集群分片
akka 集群 Sharding分片 分片上下级结构 集群(多台节点机) —> 每台节点机(1个片区) —> 每个片区(多个分片) —> 每个分片(多个实体) 实体: 分片管理的 A ...
- 自己实现IOC容器,java代码实现简易版IOC容器,IOC容器实现的步骤分解
一.需求 实现一个简易的IOC容器,管理Bean,从IOC容器的BeanFactory中获取实例,从而取代自己new实例的做法. 二.实现步骤分析 三.具体代码实现 自定义注解类 MyComponen ...
- 利用stub技术进行单元测试
待测试类:WebClient: import java.io.IOException; import java.io.InputStream; import java.net.HttpURLConne ...
- France beat Croatia 4-2 in World Cup final
France won the World Cup for the second time by beating Croatia 4-2 in a tremendous ...
- 如何在一个项目中兼容Wepy和Taro?
背景交待 NJ 项目启动初期,团队技术栈主要是基于 Vue,技术选择上就选择了类 Vue 的 wepy.迭代几个版本后 mpvue 出来了,简单调研了下,准备基于 mpvue-simple 开发部分页 ...
- MYSQL数据库数据类型
07.14自我总结 MYSQL数据库数据类型 一.整数类型和浮点数典型 1.有符号/没符号 对于整数和负整数来说,默认情况下是有符号范围的 默认是有符号 有符号和没符号其实就是有没有包括负数,有符号是 ...
- 解决tensorflow模型保存时Saver报错:TypeError: TF_SessionRun_wrapper: expected all values in input dict to be ndarray
TypeError: TF_SessionRun_wrapper: expected all values in input dict to be ndarray 对于下面的实际代码: import ...
- Linux系统安装MySQL——.rpm版
0.环境 本文操作系统: CentOS 7.2.1511 x86_64MySQL 版本: 5.7.13 1.下载 MySQL 官方的 Yum Repository 从 MySQL 官网选取合适的 My ...