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个大写字母和 ...
随机推荐
- PythonCharm 配置本地反向代理激活
以下方法仅做学习使用,如果条件允许,请自行购买正版软件,做开发的都知道软件开发出来不容易,能够支持就支持正版吧 首先去官网 下载 自己需要的 PYCHARM 版本 安装完启动会提示要激活, 选择 li ...
- html5 canvas画布上合成
source-over 默认.在目标图像上显示源图像. source-atop 在目标图像顶部显示源图像.源图像位于目标图像之外的部分是不可见的. source-in 在目标图像中显示源图像.只有目标 ...
- MFC笔记(DN)
01:MFC应用程序编程 02:MFC菜单.工具栏.状态栏 03:视图窗口
- 第10月第4天 Mac g++ sfml opendir
1. g++ OpenGL.cpp -I/Users/temp/Downloads/SFML-2.4.2-osx-clang/include -L/usr/local/lib -framework O ...
- linux磁盘已满,文件占用情况
du -sh /data0/* 如上,/data0/* 表示查看data0文件夹下各个目录的磁盘占用情况 df -h 查看总的磁盘占比
- 【Udacity并行计算课程笔记】- lesson 1 The GPU Programming Model
一.传统的提高计算速度的方法 faster clocks (设置更快的时钟) more work over per clock cycle(每个时钟周期做更多的工作) more processors( ...
- string替换所有指定字符串(C++)
C++的string提供了replace方法来实现字符串的替换,但是对于将字符串中某个字符串全部替换这个功能,string并没有实现,我们今天来做的就是这件事. 首先明白一个概念,即string替换所 ...
- 『Matplotlib』数据可视化专项
一.相关知识 官网介绍 matplotlib API 相关博客 matplotlib绘图基础 漂亮插图demo 使用seaborn绘制漂亮的热度图 fig, ax = plt.subplots(2,2 ...
- start-stop-daemon 启动停止系统守护进程
1.start-stop-daemon start-stop-daemon是一个Debian体系里的一个守护进程管理软件,可以用指定的用户启停软件.CentOS有自己的daemon()机制(在/etc ...
- win7下PHP+MySQL+CoreSeek中文检索引擎配置
1.Windows下的coreseek安装测试 (64位win7旗舰版) 官方参考:http://www.coreseek.cn/products-install/install_on_windows ...