博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Codeforces Round #280 (Div. 2) E. Vanya and Field 思维题
阅读量:6700 次
发布时间:2019-06-25

本文共 1985 字,大约阅读时间需要 6 分钟。

E. Vanya and Field
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Vanya decided to walk in the field of size n × n cells. The field contains m apple trees, the i-th apple tree is at the cell with coordinates (xi, yi). Vanya moves towards vector (dx, dy). That means that if Vanya is now at the cell (x, y), then in a second he will be at cell . The following condition is satisfied for the vector: , where is the largest integer that divides both a and b. Vanya ends his path when he reaches the square he has already visited.

Vanya wonders, from what square of the field he should start his path to see as many apple trees as possible.

Input

The first line contains integers n, m, dx, dy(1 ≤ n ≤ 106, 1 ≤ m ≤ 105, 1 ≤ dx, dy ≤ n) — the size of the field, the number of apple trees and the vector of Vanya's movement. Next m lines contain integers xi, yi (0 ≤ xi, yi ≤ n - 1) — the coordinates of apples. One cell may contain multiple apple trees.

Output

Print two space-separated numbers — the coordinates of the cell from which you should start your path. If there are several answers you are allowed to print any of them.

Sample test(s)
Input
5 5 2 3 0 0 1 2 1 3 2 4 3 1
Output
1 3
Input
2 3 1 1 0 0 0 1 1 1
Output
0 0
Note

In the first sample Vanya's path will look like: (1, 3) - (3, 1) - (0, 4) - (2, 2) - (4, 0) - (1, 3)

In the second sample: (0, 0) - (1, 1) - (0, 0)

#include 
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
typedef long long ll;using namespace std;//freopen("D.in","r",stdin);//freopen("D.out","w",stdout);#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)ll kiss[1000004];ll cnt[1000004];int main(){ sspeed; int n,m,dx,dy; int x=0,y=0; cin>>n>>m>>dx>>dy; for(int i=0;i
>x>>y; y=(n+y-kiss[x])%n; cnt[y]++; if(maxn

 

转载地址:http://rngoo.baihongyu.com/

你可能感兴趣的文章
机器学习自主解决安全威胁离我们还有多远?
查看>>
《编程珠玑(第2版•修订版)》—第2章2.2节无处不在的二分搜索
查看>>
时序数据合并场景加速分析和实现 - 复合索引,窗口分组查询加速,变态递归加速...
查看>>
当Terraform遇上ECS(一)——DataSource篇
查看>>
3月15日云栖精选夜读:双管齐下,MaxCompute数据上云与生态
查看>>
实时数据交换平台 - BottledWater-pg with confluent
查看>>
SpringMvc整合Quartz实现定时任务项目源码
查看>>
Linux 多核下绑定硬件中断到不同 CPU(IRQ Affinity)
查看>>
抽象工厂模式
查看>>
[原]小命令大作用:modprobe
查看>>
PropertyGrid控件 分类(Category)及属性(Property)排序
查看>>
属性动画基础之ValueAnimator
查看>>
登录失败时记住访问的地址
查看>>
基于用户投票的排名算法(一):Delicious和Hacker News
查看>>
JavaScript原生对象常用方法总结
查看>>
工作者对象HttpWorkerRequest
查看>>
云数据库·ApsaraDB 产品6月刊
查看>>
JS中的prototype
查看>>
【译】什么导致了Context泄露:Handler&内部类
查看>>
限制MySQL Binlog的传输速率
查看>>