2010-2011 ACM-ICPC, NEERC, Moscow Subregional Contest Problem H. Hometask 水题
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 水题的更多相关文章
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 2016-2017 ACM-ICPC, NEERC, Moscow Subregional Contest Problem L. Lazy Coordinator
题目来源:http://codeforces.com/group/aUVPeyEnI2/contest/229511 时间限制:1s 空间限制:512MB 题目大意: 给定一个n 随后跟着2n行输入 ...
- 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 ...
- 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 ...
- 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 ...
- 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个大写字母和 ...
随机推荐
- Nginx配置项优化(转载)
(1)nginx运行工作进程个数,一般设置cpu的核心或者核心数x2 如果不了解cpu的核数,可以top命令之后按1看出来,也可以查看/proc/cpuinfo文件 grep ^processor / ...
- struts的理解
1.struts是一个按MVC模式设计的Web层框架,其实他就是一个大大的servlet,这个Servlet名为ActionServlet,或是ActionServlet的子类.我们可以在web.xm ...
- 20155230 2016-2017-2 《Java程序设计》第五周学习总结
20155230 2016-2017-2 <Java程序设计>第五周学习总结 教材学习内容总结 1.错误处理通常称为异常处理. 2.catch括号中列出的异常不得有继承关系,否则会发生编译 ...
- nmap - 网络扫描
NMap,Network Mapper 最早是Linux下的网络扫描和嗅探工具包 网络链接扫描; nmap -PT 192.168.1.1-111 # 先ping在扫描主机开放端口 nmap -O 1 ...
- 第6月第17天 CGAffineTransformMake(a,b,c,d,tx,ty) 矩阵运算的原理
1. 为了把二维图形的变化统一在一个坐标系里,引入了齐次坐标的概念,即把一个图形用一个三维矩阵表示,其中第三列总是(0,0,1),用来作为坐标系的标准.所以所有的变化都由前两列完成. 以上参数在矩阵中 ...
- 360 / 小米 / 百度 随身wifi Ubuntu 下作为无线网卡使用
这篇文章说得其实很好了,http://www.freemindworld.com/blog/2013/131010_360_wifi_in_linux.shtml 不过因为专利问题,官网貌似不直接提供 ...
- Java NIO 之 Buffer(缓冲区)
一 Buffer(缓冲区)介绍 Java NIO Buffers用于和NIO Channel交互. 我们从Channel中读取数据到buffers里,从Buffer把数据写入到Channels. Bu ...
- cmd命令,bat脚本
1.cd /d D:\>cd mysql D:\mysql>cd /d C:/TEMP C:\Temp>cd /? 显示当前目录名或改变当前目录. CHDIR [/D] [drive ...
- slf4j MDC使用
slf4j MDC使用 最近也是在项目代码里发现一个地方有个MDC.put(),忍不住好奇点了进去,于是知道了MDC这个东西,细研究一下,发现还真是个好东西. MDC解决了什么问题 MDC全名Mapp ...
- OE中的bitbake使用
OpenEmbedded是一些脚本(shell和python脚本)和数据构成的自动构建系统. 脚本实现构建过程,包括下载(fetch).解包(unpack).打补丁(patch).config ...