Chladni Figure CodeForces - 1162D

Inaka has a disc, the circumference of which is nn units. The circumference is equally divided by nn points numbered clockwise from 11 to nn, such that points ii and i+1i+1 (1≤i<n1≤i<n) are adjacent, and so are points nn and 11.

There are mm straight segments on the disc, the endpoints of which are all among the aforementioned nn points.

Inaka wants to know if her image is rotationally symmetrical, i.e. if there is an integer kk (1≤k<n1≤k<n), such that if all segments are rotated clockwise around the center of the circle by kk units, the new image will be the same as the original one.

Input

The first line contains two space-separated integers nn and mm (2≤n≤1000002≤n≤100000, 1≤m≤2000001≤m≤200000) — the number of points and the number of segments, respectively.

The ii-th of the following mm lines contains two space-separated integers aiai and bibi (1≤ai,bi≤n1≤ai,bi≤n, ai≠biai≠bi) that describe a segment connecting points aiai and bibi.

It is guaranteed that no segments coincide.

Output

Output one line — "Yes" if the image is rotationally symmetrical, and "No" otherwise (both excluding quotation marks).

You can output each letter in any case (upper or lower).

Examples

Input
  1. 12 6
  2. 1 3
  3. 3 7
  4. 5 7
  5. 7 11
  6. 9 11
  7. 11 3
Output
  1. Yes
Input
  1. 9 6
  2. 4 5
  3. 5 6
  4. 7 8
  5. 8 9
  6. 1 2
  7. 2 3
Output
  1. Yes
Input
  1. 10 3
  2. 1 2
  3. 3 2
  4. 7 2
Output
  1. No
Input
  1. 10 2
  2. 1 6
  3. 2 7
Output
  1. Yes

Note

The first two examples are illustrated below. Both images become the same as their respective original ones after a clockwise rotation of 120120 degrees around the center.

题意:在圆上有n个点和m条线段,问圆上这个图形在通过旋转是否能找到一个位置与之前的图形完全重合。

解法:暴力就完事了,开vector数组来存储两个点之间是否相连

   如果要重合的话,那么旋转的长度必定要被N整除。//剪枝情况

   先比较对应位置的点具有关系的线段数量是否相等,然后将对应点所存储的线段长度转移到int类型的数组冲进行排序比较。在比较过程中如果出现不相等的情况即跳出当前循环。

在此说一句:金大佬太强了! 暴力真香~

  1. #include<stdio.h>
  2. #include<string.h>
  3. #include<iostream>
  4. #include<algorithm>
  5. #include<map>
  6. #include<string>
  7. #include<set>
  8. #include<stack>
  9. #include<queue>
  10. using namespace std;
  11. const int maxn = ;
  12. vector<int>v[];
  13. int a[maxn],b[maxn];
  14. int x,y,n,m;
  15.  
  16. int sum(int x ,int y){//保证相关线段是最短的并且不是负数
  17. if( x > y){
  18. return min(x - y,y - x + n);
  19. }else{
  20. return min(y - x, x - y + n);
  21. }
  22. }
  23. int main(){
  24. scanf("%d %d",&n,&m);
  25. for(int i = ; i <= m ; i++){
  26. scanf("%d %d",&x,&y);
  27. v[x].push_back(y);//v[x]存储以v[x]为起点的线段
  28. v[y].push_back(x);
  29. }
  30. int ret = ;
  31. for(int i = ; i < n ; i++){
  32. if(n % i == ){
  33. int flag = ;
  34. for(int j = ; j <= n ; j++){
  35. if(v[j].size() != v[(j + i - )%n + ].size()){//如果对应点所具有的线段的数量不相等,则图形不可能重合
  36. flag = ;
  37. break;
  38. }
  39. int l = v[j].size();//对应点线段数量相等之后,将对应点所存的线段提取到a[],b[]数组中,排序后进行比较
  40. for(int k = ; k < l ; k++ ){
  41. a[k] = sum(v[j][k],j);
  42. b[k] = sum(v[(j + i - )%n + ][k],(j + i - )%n+);
  43. }
  44. sort(a,a+v[j].size());//将对应点中所有的线段进行排序
  45. sort(b,b+v[j].size());
  46. for(int k = ; k < l; k++){
  47. if(a[k] != b[k]){
  48. flag = ;
  49. break;
  50. }
  51. }
  52. }
  53. if(flag){
  54. printf("Yes\n");
  55. ret = ;
  56. break;
  57. }
  58. }
  59. }
  60. if(ret) printf("No\n");
  61. return ;
  62. }

AC代码

一个从很久以前就开始做的梦。

Chladni Figure CodeForces - 1162D (暴力,真香啊~)的更多相关文章

  1. 从Eclipse切换到IDEA工具,哎~真香!

    从Eclipse切换到IDEA工具,哎~真香!(图) 个人观点:IDEA工具用了就回不去了!!!对比很多人写,我就不赘述了.我在这里主要介绍一下IDEA工具的一些使用上的技巧,毕竟我开始学习java的 ...

  2. git 日常使用从入门到真香

    目录 git 日常使用从入门到真香 一.Git简介 二.Git常用命令 三.git操作流程 四.报错处理 git 日常使用从入门到真香 一.Git简介 Git是一个开源的分布式版本控制系统,可以有效. ...

  3. 真香系列之 Golang 升级

    Golang 以前的依赖管理一直饱受诟病,社区的方案也层出不穷,比如 vendor, glide, godep 等.之前的依赖管理一直是依靠 GOPATH 或者将依赖代码下载到本地,这种方式都有劣势. ...

  4. 真香的flex弹性布局

    如何实现一个左中右的布局 在flex出现之前 #box{ color: white; } #left{ float: left; width: 30%; background-color: red; ...

  5. VSCode六大通用插件真香合集

    目录 一.background:设置心水背景图 安利理由: 安装及设置步骤: 设置过程中使用的代码: 成果展示: 注意: 二.Material Theme(VSCode主题)+Material Ico ...

  6. 曾经你说chrome浏览器天下第一,现在你却说Microsoft edge真香!呸,渣男!!

    曾经你说chrome浏览器天下第一,现在你却说Microsoft edge真香!呸,渣男!! 一个月前我每天打卡搜索的时候,老是有微软新版浏览器的广告.我刚才是内心其实是抵触的,直到我发现了它的奇妙之 ...

  7. JavaFX桌面应用-MVC模式开发,“真香”

    使用mvc模块开发JavaFX桌面应用在JavaFX系列文章第一篇 JavaFX桌面应用开发-HelloWorld 已经提到过,这里单独整理使用mvc模式开发开发的流程. ~ JavaFX桌面应用开发 ...

  8. 国人开源了一款超好用的 Redis 客户端,真香!!

    大家都知道,Redis Desktop Manager 是一款非常好用的 Redis 可视化客户端工具,但可惜的是 v0.9.4 版本之后需要收费了: 这个工具不再免费提供安装包了,要对所有安装包收费 ...

  9. 我把公司 10 年老系统改造 Maven,真香!!

    公司有几个老古董项目,应该是 10 年前开发的了,有一个是 JSP + Servlet,有一个还用的 SSH 框架,打包用的 Ant,是有多老啊,我想在座的各位很多都没听过吧. 为了持续集成.持续部署 ...

随机推荐

  1. Centos7.4 kafka集群安装与kafka-eagle1.3.9的安装

    Centos7.4 kafka集群安装与kafka-eagle1.3.9的安装 集群规划: hostname Zookeeper Kafka kafka-eagle kafka01 √ √ √ kaf ...

  2. 二、【未来】React环境安装:npx

    搭建React的开发环境的第二种方法(新-未来推荐): https://reactjs.org/docs/create-a-new-react-app.html 一. npx简介: 1. npm v5 ...

  3. Scrapy的学习和使用

    1.安装 在windows下安装是真心复杂,不搞了,直接在linux下研究吧! sudo pip install scrapy 2.安装遇到问题 2.1.bz2 module not availabl ...

  4. C语言:大数求和

    点击获取题目 1410: [蓝桥杯]高精度加法 时间限制: 1 Sec  内存限制: 256 MB提交: 28  解决: 20[状态] [提交] [命题人:外部导入] 题目描述 输入两个整数a和b,输 ...

  5. [Python3] RSA的加解密和签名/验签实现 -- 使用pycrytodome

    Crypto 包介绍: pycrypto,pycrytodome 和 crypto 是一个东西,crypto 在 python 上面的名字是 pycrypto 它是一个第三方库,但是已经停止更新,所以 ...

  6. 四、SAP中转义字符的使用和不同数据类型所占长度不同

    一.代码如下: 效果如下,注意看,数字类型占用了10个位置:

  7. java内存模型一

    Java平台自动集成了线程以及多处理器技术,这种集成程度比Java以前诞生的计算机语言要厉害很多,该语言针对多种异构平台的平台独立性而使用的多线程技术支持也是具有开拓性的一面,有时候在开发Java同步 ...

  8. UVA_12697 满足条件的最短连续和 线段树维护

    好印象深刻的题,前天选拔赛给跪了.怪我这种关键题没敲出来. 题意很简单,给你一串无规则的数列,再给个m值,求出满足 数列和>=m的长度最小的连续子串...确实一开始卡住了,因为看数据肯定是nlo ...

  9. 吴裕雄--天生自然JAVA SPRING框架开发学习笔记:Spring AOP(面向切面编程)

    面向切面编程(AOP)和面向对象编程(OOP)类似,也是一种编程模式.Spring AOP 是基于 AOP 编程模式的一个框架,它的使用有效减少了系统间的重复代码,达到了模块间的松耦合目的. AOP ...

  10. POJ - 3279 Fliptile(反转---开关问题)

    题意:有一个M*N的网格,有黑有白,反转使全部变为白色,求最小反转步数情况下的每个格子的反转次数,若最小步数有多个,则输出字典序最小的情况.解不存在,输出IMPOSSIBLE. 分析: 1.枚举第一行 ...