这个题好像可以直接暴力过。我是先用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. [转载]浅谈JavaScript函数重载

     原文地址:浅谈JavaScript函数重载 作者:ChessZhang 上个星期四下午,接到了网易的视频面试(前端实习生第二轮技术面试).面了一个多小时,自我感觉面试得很糟糕的,因为问到的很多问题都 ...

  2. 【记录】@Transactional

    参考链接:https://blog.csdn.net/nextyu/article/details/78669997 参考链接:https://www.xuebuyuan.com/3222458.ht ...

  3. 2019-5-28-VisualStudio-扩展开发

    title author date CreateTime categories VisualStudio 扩展开发 lindexi 2019-05-28 19:51:49 +0800 2018-2-1 ...

  4. leetcode69. x 的平方根 🌟

    题目: 实现 int sqrt(int x) 函数. 计算并返回 x 的平方根,其中 x 是非负整数. 由于返回类型是整数,结果只保留整数的部分,小数部分将被舍去. 示例 1: 输入: 4 输出: 2 ...

  5. wireshare文件格式

    你用Wireshark打开这个pkt试试,如果可以打开,就说明Wireshark支持这种格式.然后你就可以去看Wireshark的源码.*.pkt是omnipeek/etherpeek的默认文件格式, ...

  6. man(2) readv writev

    #include <sys/uio.h> ssize_t readv(int fd, const struct iovec *iov, int iovcnt); unix高级环境编程中的定 ...

  7. JFreeChart使用

    最近项目需要做图形分析,就想到了使用JFreeChart,之前也没有使用过,就现学先用吧.本文主要记录一些主要的代码及学习使用过程. 使用JFreeChart步骤: 一.下载JFreeChart.ja ...

  8. 牛客CSP-S提高模拟4 赛后总结

    前言 其实前面已经打了 3 场牛客 3 场计蒜客的比赛,都没有写总结,今天先提一下以前的情况 计蒜客 1 :0+0+0 = 0 (心态崩了,写挂了) 牛客 1: 0+0+0 = 0 (T1博弈论,T2 ...

  9. 进程间的mutex

    设两个进程共用一个临界资源的互斥信号量mutex=1,当mutex=-1时表示(). 一个进程进入了临界区,另一个进程等待 没有一个进程进入临界区 两个进程都进入临界区 两个进程都在等待 互斥信号量不 ...

  10. 打开pycharm提示python已停止工作

    今天遇到一个棘手的问题: 现象:打开pycharm,立刻提示python已停止工作,关掉后还会弹出一个新的,就是永远维持至少一个提醒框在界面的状态 解决过程: 方法一:然后在网上搜解决办法,有一个主流 ...