Codeforces Round #280 (Div. 2) E. Vanya and Field
来源:互联网 发布:淘宝爆款怎样打造爆款 编辑:程序博客网 时间:2024/04/29 07:59
题意:
给你一个 N*N 的矩阵,上面有 M 个苹果树,有一个人移动的单位向量为(dx ,dy),且 dx,dy 和 N 互质;求从何处出发可以经过尽可能多的苹果树
解题报告:
因为移动的单位向量和 N 互质,所以那个人走 N 次单位向量的距离就刚好回到出发点,将从(0, 0)点出发的这 N 个点的向量记录出来,刚好作为位移的偏移量
记录每一个苹果树是属于哪一类出发点,就是记录它相对的偏移量。
取最大的偏移量,就是答案。
// whn6325689#include <algorithm>#include <iostream>#include <iomanip>#include <cstring>#include <climits>#include <complex>#include <fstream>#include <cassert>#include <cstdio>#include <bitset>#include <vector>#include <deque>#include <queue>#include <stack>#include <ctime>#include <set>#include <map>#include <cmath>#include <functional>#include <numeric>using namespace std;typedef long long ll;typedef long double ld;typedef pair<ll, ll> pll;typedef complex<ld> point;typedef pair<int, int> pii;typedef pair<pii, int> piii;typedef vector<int> vi;#define CLR(x,y) memset(x,y,sizeof(x))#define mp(x,y) make_pair(x,y)#define pb(x) push_back(x)#define lowbit(x) (x&(-x))#define MID(x,y) (x+((y-x)>>1))#define eps 1e-9#define INF 0x3f3f3f3f#define LLINF 1LL<<62template<class T>inline bool read(T &n){ T x = 0, tmp = 1; char c = getchar(); while((c < '0' || c > '9') && c != '-' && c != EOF) c = getchar(); if(c == EOF) return false; if(c == '-') c = getchar(), tmp = -1; while(c >= '0' && c <= '9') x *= 10, x += (c - '0'),c = getchar(); n = x*tmp; return true;}template <class T>inline void write(T n){ if(n < 0) { putchar('-'); n = -n; } int len = 0,data[20]; while(n) { data[len++] = n%10; n /= 10; } if(!len) data[len++] = 0; while(len--) putchar(data[len]+48);}//-----------------------------------const int MAXN=1000100;int sum[MAXN];int d[MAXN];int n;#define mod(x) (x+n)%nint main(){ int m,dx,dy; read(n),read(m),read(dx),read(dy); int v=0; long long u = 0; while(1) { d[v]=u; v=(v+dx)%n; if(!v) break; u=(u+dy)%n; } for(int i=0; i<m; i++) { read(u),read(v); sum[mod(v-d[u])]++; } int p=0; for(int i=1; i<n; i++) if(sum[i] > sum[p]) p=i; write(0),putchar(' '); write(p),putchar('\n'); return 0;}
0 0
- Codeforces Round #280 (Div. 2) E. Vanya and Field
- cf Round #280 (Div. 2) E. Vanya and Field 数学
- Codeforces Round #280 (Div. 2) E. Vanya and Field (数学GCD)
- Codeforces #280 Div.2 E.Vanya and Field 数学,数论
- E. Vanya and Brackets(Codeforces Round #308 (Div. 2))
- Codeforces Round #308 (Div. 2) E. Vanya and Brackets
- Codeforces Round #355 (Div. 2)E. Vanya and Balloons
- CodeForces #280 E Vanya and Field
- Codeforces Round #280 (Div. 2) C. Vanya and Exams
- (Vanya and Lanterns)Codeforces Round #280 (Div. 2)B
- Vanya and Lanterns( Codeforces Round #280 (Div. 2)B)
- Codeforces Round #280 (Div. 2)_C. Vanya and Exams
- Codeforces Round #280 (Div. 2)-D. Vanya and Computer Game
- CodeForces 492E Vanya and Field
- Codeforces Round #235 (Div. 2) A. Vanya and Cards
- A. Vanya and Table(Codeforces Round #308 (Div. 2))
- B. Vanya and Books(Codeforces Round #308 (Div. 2))
- C. Vanya and Scales(Codeforces Round #308 (Div. 2))
- 架构之美第七章-软件架构师的角色
- 架构之美第八章-软件架构的含义
- 架构之美第九章-架构与设计
- ios邓白氏申请
- 【jQWidgets】API 笔记
- Codeforces Round #280 (Div. 2) E. Vanya and Field
- NYOJ 122、124、125
- 架构之美第十章-创建软件架构
- 架构之美第十一章-架构结构
- QT中动态链接库的建立,以及在QT中的引用,C++程序中的引用
- Undefined symbols for architecture xxx
- 架构之美第十二章-好的架构
- webmagic学习笔记
- http://blog.sina.com.cn/s/blog_62714d6a0100mjgs.html