Problem H. Hometask

题目连接:

http://codeforces.com/gym/100714

Description

Kolya is still trying to pass a test on Numbers Theory. The lecturer is so desperate about Kolya’s

knowledge that she gives him the same task every time.

The problem is to check if N! is divisible by N2

.

Input

The first line of input contains the only integer N (1 ≤ N ≤ 109

).

Output

Please, print to output “YES” provided that N! is divisible by N2

, otherwise print “NO”.

Sample Input

3

Sample Output

NO

Hint

题意

问你n!%n^2 == 0?

题解:

暴力分解N的质因数就好了,然后看一看就好了……

代码

#include <bits/stdc++.h>
#define rep(a,b,c) for(int (a)=(b);(a)<=(c);++(a))
#define drep(a,b,c) for(int (a)=(b);(a)>=(c);--(a))
#define pb push_back
#define mp make_pair
#define sf scanf
#define pf printf
#define two(x) (1<<(x))
#define clr(x,y) memset((x),(y),sizeof((x)))
#define dbg(x) cout << #x << "=" << x << endl;
const int mod = 1e9 + 7;
int mul(int x,int y){return 1LL*x*y%mod;}
int qpow(int x , int y){int res=1;while(y){if(y&1) res=mul(res,x) ; y>>=1 ; x=mul(x,x);} return res;}
inline int read(){int x=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}return x*f;}
using namespace std;
const int maxn = 1e5 + 50; int pre[maxn] , prime[maxn] , priemlen;
vector < int > vi;
map < int , int > fac; void init(){
for(int i = 2 ; i < maxn ; ++ i) if(!pre[i]){
prime[priemlen ++ ] = i;
for(int j = i ; j < maxn ; j += i )pre[j] = i;
}
} void dfs( int x , int y ){
if( x < maxn ){
while( x > 1 ){
vi.pb( pre[x] ) ;
x /= pre[x];
}
}else{
for( int i = y ; ; ++ i) if( x % prime[i] == 0 ){
vi.pb( prime[i] );
dfs( x / prime[i] , i );
return ;
}else if( 1LL * prime[i] * prime[i] > x ) break;
vi.pb( x );
}
} bool judge( int N ){
vi.clear();
fac.clear();
dfs( N , 0 );
sort( vi.begin() , vi.end() );
for(auto it : vi) fac[it] ++ ;
for(auto it : fac){
int v = it.first , num = it.second;
if( ( N - 1 ) / v < num ) return false;
}
return true;
} bool baoli( int N ){
int x = 1 ;
for(int i = 1 ; i < N ; ++ i) x = x * i % N;
return x == 0;
} int main(int argc,char *argv[]){
int N;
cin >> N;
init();
if(N == 1) cout << "YES" << endl;
else{
if( judge( N ) ) cout << "YES" << endl;
else cout << "NO" << endl;
} return 0;
}

2010-2011 ACM-ICPC, NEERC, Moscow Subregional Contest Problem H. Hometask 水题的更多相关文章

  1. 2010-2011 ACM-ICPC, NEERC, Moscow Subregional Contest Problem J. Joke 水题

    Problem J. Joke 题目连接: http://codeforces.com/gym/100714 Description The problem is to cut the largest ...

  2. 2010-2011 ACM-ICPC, NEERC, Moscow Subregional Contest Problem F. Finance 模拟题

    Problem F. Finance 题目连接: http://codeforces.com/gym/100714 Description The Big Boss Company (BBC) pri ...

  3. 2010-2011 ACM-ICPC, NEERC, Moscow Subregional Contest Problem D. Distance 迪杰斯特拉

    Problem D. Distance 题目连接: http://codeforces.com/gym/100714 Description In a large city a cellular ne ...

  4. 2010-2011 ACM-ICPC, NEERC, Moscow Subregional Contest Problem C. Contest 水题

    Problem C. Contest 题目连接: http://codeforces.com/gym/100714 Description The second round of the annual ...

  5. 2016-2017 ACM-ICPC, NEERC, Moscow Subregional Contest Problem L. Lazy Coordinator

    题目来源:http://codeforces.com/group/aUVPeyEnI2/contest/229511 时间限制:1s 空间限制:512MB 题目大意: 给定一个n 随后跟着2n行输入 ...

  6. 2010-2011 ACM-ICPC, NEERC, Moscow Subregional Contest Problem K. KMC Attacks 交互题 暴力

    Problem K. KMC Attacks 题目连接: http://codeforces.com/gym/100714 Description Warrant VI is a remote pla ...

  7. 2010-2011 ACM-ICPC, NEERC, Moscow Subregional Contest Problem I. Interest Targeting 模拟题

    Problem I. Interest Targeting 题目连接: http://codeforces.com/gym/100714 Description A unique display ad ...

  8. 2010-2011 ACM-ICPC, NEERC, Moscow Subregional Contest Problem A. Alien Visit 计算几何

    Problem A. Alien Visit 题目连接: http://codeforces.com/gym/100714 Description Witness: "First, I sa ...

  9. 2014-2015 ACM-ICPC, NEERC, Eastern Subregional Contest Problem H. Pair: normal and paranormal

    题目链接:http://codeforces.com/group/aUVPeyEnI2/contest/229669 时间限制:1s 空间限制:64MB 题目大意:给定一个长度为2n,由n个大写字母和 ...

随机推荐

  1. python AjaxSpider 代码演示

    import re # 引入正则表达式 import json # 引入 json import pymongo # 引入mongo数据库 import requests # 引入HTTP请求协议 f ...

  2. CSS规范 - 命名规则--(来自网易)

    使用类选择器,放弃ID选择器 ID在一个页面中的唯一性导致了如果以ID为选择器来写CSS,就无法重用. NEC特殊字符:"-"连字符 "-"在本规范中并不表示连 ...

  3. [转载]Web API OData Inlinecount not working

    http://stackoverflow.com/questions/15422831/web-api-odata-inlinecount-not-working

  4. tensorflow的卷积和池化层(二):记实践之cifar10

    在tensorflow中的卷积和池化层(一)和各种卷积类型Convolution这两篇博客中,主要讲解了卷积神经网络的核心层,同时也结合当下流行的Caffe和tf框架做了介绍,本篇博客将接着tenso ...

  5. spring如何管理mybatis(二) ----- SqlSession的线程安全性

    在之前的文章中我们了解到最终的数据库最终操作是走的代理类的方法: @Override public Object invoke(Object proxy, Method method, Object[ ...

  6. Django进阶之session

    基于cookie做用户验证时:敏感信息不适合放在cookie中 session依赖cookie session原理 cookie是保存在用户浏览器端的键值对 session是保存在服务器端的键值对 s ...

  7. websocket知识简单总结!

    <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title&g ...

  8. GBDT理解

    一.提升树 提升方法实际采用加法模型(即基函数的线性组合)与前向分布算法.以决策树为基函数的提升方法称为提升树,boosting tree.对分类问题的决策树是二叉分类树,对回归问题的决策树是二叉回归 ...

  9. 【腾讯云】自己搭建的腾讯云服务器JavaEE环境

    0.安装SSH登录 1.生成公钥对 ssh-keygen -t rsa -P '' -P表示密码,-P '' 就表示空密码,也可以不用-P参数,这样就要三车回车,用-P就一次回车.它在/home/ch ...

  10. 002_tmux详解

    参考下赖老师的: http://mingxinglai.com/cn/2012/09/tmux/ 一. 二. http://wdxtub.com/2016/03/30/tmux-guide/   (待 ...