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个大写字母和 ...
随机推荐
- HDU 3595 every-sg模型
多个子游戏同时进行,每个子游戏给出两个数a,b,可以将大的数减去k倍小的数,不能操作者输. 策略就是对于一个必胜的游戏要使得步数更长,对于一个必败的游戏使得步数最短. 以下都来自贾志豪的论文.. 对于 ...
- 流媒体技术学习笔记之(十四)FFmpeg进行笔记本摄像头+麦克风实现流媒体直播服务
FFmpeg推送视频流,Nginx RTMP模块转发,VLC播放器播放,实现整个RTMP直播 查看本机电脑的设备 ffmpeg -list_devices true -f dshow -i dummy ...
- 学了display:flex垂直居中容易多了
以前div内部的文字垂直居中,使用height = line-height,现在可以使用display:flex来实现了 .div{ display:flex; align-items:center; ...
- shell 流程结构
if 判断语句 if [ $a == $b ] then echo "等于" else echo "不等于" fi case分支选择 case $xs in ) ...
- Django安装配置
django2.0基础 一.安装与项目的创建 1.安装 pip install django 2.查看版本 python -m django --version 3.创建项目 django-admin ...
- Linux中Samba详细安装【转】
转自:http://www.cnblogs.com/whiteyun/archive/2011/05/27/2059670.html 为了实现Windows主机与Linux服务器之间的资源共享,Lin ...
- innobackupex做MySQL增量备份及恢复【转】
创建备份用户 mysql> grant process,reload,lock tables,replication client on *.* to 'backup'@'localhost' ...
- zabbix3.0配置服务器流量告警
zabbix配置流量告警 zabbix虽然已经对服务器的网卡流量进行了监控,但为了防止某台机器流量过高导致网络慢,或者因为中病毒或木马等原因,导致流量很高,可使用zabbix的流量告警功能来对流量进行 ...
- poj1521
霍夫曼编码,建树 #include <cstdio> #include <cstring> #include <queue> using namespace std ...
- C++ Primer读书笔记(3)
vector: 本科时学C++的时候没学过vector,正好补一下. 第一个要注意的地方是要正确区分列表初始值还是元素数量. 第二点是不能使用范围for向vector对象添加元素,范围for语句体内不 ...