这个题好像可以直接暴力过。我是先用num[len]统计所有每个长度的数量有多少,假如在长度为len下,如果要考虑旋转后和原来图案保持一致,我们用a表示在一个旋转单位中有几个长度为len的线段,b表示有几个这样的旋转单位,那么可以表示a*b=num[len],满足这样的a,b一定可以满足要求,这时候就可以发现只需要枚举因子暴力扫过去即可,我们用map存下所有点的位置,在枚举块的数量时是直接可以算出旋转角,那我们直接对所有点进行判断,旋转后是否存在这样的一个点。有一个坑,当num[len]长度为1时,只存在n==2时满足要求,其他的时候是不可能存在,这里要进行特判。

 //      ——By DD_BOND 

 //#include<bits/stdc++.h>
#include<functional>
#include<algorithm>
#include<iostream>
#include<sstream>
#include<iomanip>
#include<climits>
#include<cstring>
#include<cstdlib>
#include<cstddef>
#include<cstdio>
#include<memory>
#include<vector>
#include<cctype>
#include<string>
#include<cmath>
#include<queue>
#include<deque>
#include<ctime>
#include<stack>
#include<map>
#include<set> #define fi first
#define se second
#define MP make_pair
#define pb push_back
#define INF 0x3f3f3f3f
#define pi 3.1415926535898
#define lowbit(a) (a&(-a))
#define lson l,(l+r)/2,rt<<1
#define rson (l+r)/2+1,r,rt<<1|1
#define Min(a,b,c) min(a,min(b,c))
#define Max(a,b,c) max(a,max(b,c))
#define debug(x) cerr<<#x<<"="<<x<<"\n"; using namespace std; typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef unsigned long long ull; const ll LLMAX=2e18;
const int MOD=1e9+;
const double eps=1e-;
const int MAXN=1e6+; inline ll sqr(ll x){ return x*x; }
inline int sqr(int x){ return x*x; }
inline double sqr(double x){ return x*x; }
ll gcd(ll a,ll b){ return b==? a: __gcd(b,a%b); }
ll exgcd(ll a,ll b,ll &x,ll &y){ ll d; (b==? (x=,y=,d=a): (d=exgcd(b,a%b,y,x),y-=a/b*x)); return d; }
ll qpow(ll a,ll n){ll sum=;while(n){if(n&)sum=sum*a%MOD;a=a*a%MOD;n>>=;}return sum;}
inline int dcmp(double x){ if(fabs(x)<eps) return ; return (x>? : -); } P que[MAXN];
int num[MAXN];
map<int,map<int,int> >mp; int main(void)
{
ios::sync_with_stdio(false); cin.tie(); cout.tie();
int n,m,l,r,len; cin>>n>>m;
if(n==) return cout<<"YES"<<endl,;
for(int i=;i<m;i++){
cin>>l>>r;
len=min((r-l+n)%n,n-(r-l+n)%n);
mp[l][r]=mp[r][l]=;
num[len]++;
que[i]=P(l,r);
}
for(int i=;i*i<=num[len];i++){
if(num[len]%i==){
if(i!=&&n%i==){
int flag=,d=n/i;
for(int j=;j<m;j++){
int l=que[j].fi,r=que[j].se,ld=l+d,rd=r+d;
if(ld>n) ld-=n;
if(rd>n) rd-=n;
if(mp[ld].find(rd)==mp[ld].end()){
flag=;
break;
}
}
if(!flag) return cout<<"Yes"<<endl,;
}
if(num[len]/i!=&&n%(num[len]/i)==){
int flag=,d=n/(num[len]/i);
for(int j=;j<m;j++){
int l=que[j].fi,r=que[j].se,ld=l+d,rd=r+d;
if(ld>n) ld-=n;
if(rd>n) rd-=n;
if(mp[ld].find(rd)==mp[ld].end()){
flag=;
break;
}
}
if(!flag) return cout<<"Yes"<<endl,;
}
}
}
cout<<"No"<<endl;
return ;
}

Codeforces 1162D Chladni Figure(枚举因子)的更多相关文章

  1. Chladni Figure CodeForces - 1162D (暴力,真香啊~)

    Chladni Figure CodeForces - 1162D Inaka has a disc, the circumference of which is nn units. The circ ...

  2. 洛谷-P1414 又是毕业季II -枚举因子

    P1414 又是毕业季II:https://www.luogu.org/problemnew/show/P1414 题意: 给定一个长度为n的数列.要求输出n个数字,每个数字代表从给定数列中最合理地取 ...

  3. codeforces 895A Pizza Separation 枚举

    codeforces 895A Pizza Separation 题目大意: 分成两大部分,使得这两部分的差值最小(注意是圆形,首尾相连) 思路: 分割出来的部分是连续的,开二倍枚举. 注意不要看成0 ...

  4. 【cf842C】 Ilya And The Tree(dfs、枚举因子)

    C. Ilya And The Tree 题意 给一棵树求每个点到根的路上允许修改一个为0,gcd的最大值. 题解 g是从根到当前点允许修改的最大gcd,gs为不修改的最大gcd.枚举当前点的因子,更 ...

  5. Educational Codeforces Round 61 C 枚举 + 差分前缀和

    https://codeforces.com/contest/1132/problem/C 枚举 + 差分前缀和 题意 有一段[1,n]的线段,有q个区间,选择其中q-2个区间,使得覆盖线段上的点最多 ...

  6. Vasya and Beautiful Arrays CodeForces - 354C (数论,枚举)

    Vasya and Beautiful Arrays CodeForces - 354C Vasya's got a birthday coming up and his mom decided to ...

  7. hdu5108枚举因子求最小的m

    题意:      给一个n(<=10Y),然后让找到一个最小的m使得n/m是一个素数. 思路:       先用sqrt(n)的时间把所有的因子都求出来,然后在排序,枚举,就行了,这个题目这么做 ...

  8. CodeForces 617C【序枚举】

    题意: 有两个点喷水,有很多个点有花,给出坐标. 求使得每个花都可以被喷到,两个喷水的半径的平方的和最小是多少. 思路: 枚举其中一个喷水的最大半径. 坑: 这题我贪心的思路有很大问题.一开始也是想这 ...

  9. codeforces 613B B. Skills(枚举+二分+贪心)

    题目链接: B. Skills time limit per test 2 seconds memory limit per test 256 megabytes input standard inp ...

随机推荐

  1. Composer简介与下载安装

    简介: 初次接触Composer的PHP程序员可能是需要下载ThinkPHP框架(5.1),那么什么是Composer,怎么下载安装呢? Composer是一个依赖管理工具,下载管理第三方包是其主要功 ...

  2. 12.解决SUSE Linux无法使用SSH登录的问题

    问题: SUSE_Linux 无法使用SSH连接登录. 解决: 1.关闭防火墙命令如下: linux:~ # /etc/init.d/SuSEfirewall2_init stop linux:~ # ...

  3. 一、JQJson数组

    叙述:常用的数据格式无非三种(组装数据,传参传值) 一.数组 : 1.定义 var select = []; //或 var select = new Array(); 2.JS给一个数组赋值 sel ...

  4. idea hibernate console 执行hql报错

    报错信息 hql> select a from GDXMZD a[2019-08-29 13:45:01] org.hibernate.service.spi.ServiceException: ...

  5. 浅谈ContextLoaderListener及其上下文与DispatcherServlet的区别

    一般在使用SpingMVC开发的项目中,一般都会在web.xml文件中配置ContextLoaderListener监听器,如下: <listener> <listener-clas ...

  6. [web 安全] php随机数安全问题

    and() 和 mt_rand() 产生随机数srand() 和 mt_srand() 播种随机数种子(seed)使用: <?php srand(123);//播种随机数种子 for($i=0; ...

  7. Jquery异步上传文件

    我想通过jQuery异步上传文件,这是我的HTML: 1 2 3 <span>File</span> <input type="file" id=&q ...

  8. 前端每日实战:98# 视频演示如何用纯 CSS 创作一只愤怒小鸟中的绿猪

    效果预览 按下右侧的"点击预览"按钮可以在当前页面预览,点击链接可以全屏预览. https://codepen.io/comehope/pen/VBGWqX 可交互视频 此视频是可 ...

  9. ZROI2019 提高十连测

    额 掰手指头一数 特么又是第三年十连测了= = 2017一场没打 那时候好像一场比赛也就100人左右 2018前几场还都好好补了 后来开始放飞自我了 这时候一场有150人还多了 2019想让今年的No ...

  10. php7 mysqli_query返回1 , 但是更新失败

    HTML中忘了传id