ACM ICPC 2010-2011 Neerc Moscow subregional Contest Moscow, October 24, 2010
Problem H. hometask
Time Limit:1 Second
Memory limit:256 Megabytes
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 n^2.
Input
The first line of input contains the only integer N (1≤n≤10^9).
Output
Please, print to output ' YES ' provided that N! is divisible by N2, otherwise print "NO".
Examples
stdin stdout
3 NO
9 YES
Note
N! = 1 · 2 · . . . · N
Source
Moscow Subregional 2010
My Solution
Prime number Screening
First, n^2 is divisible by n!.
i.e. N is (N-1)! Divisible
Arbitrarily basically as long as N is not a prime number can have a constraint other than N and 1,
So as long as the prime number is NO
Also for 4 because only 1 2 4 so the number of pages does not meet N is (N-1)! divisible, so 4 special treatment no//good caution, by the way, or 4 of special treatment may have to WA and later found
0! is 1 so N = = 1 also satisfies 1^1 is divisible by 1 YES
Complexity O (sqrt (n))
The code was implemented by the teammates, so the AC code was cs_lyj1997 to the teammate.
In addition we have also had another 2 questions, but that 2 questions, the author did not participate, so do not tidy up
#include <iostream> #include <cmath>using namespace Std;int main () { int n,i; bool F; F=false; cin>>n; for (I=2;I<=SQRT (n); i++) if (n%i==0) f=true; if (n==1) f=true; if (!f | | n==4) cout<< "NO" <<endl; else cout<< "YES" <<endl; return 0;}
Thank you!
------ from Prolights
Moscow subregional problem H. hometask conversion, prime number screening