N!是否能被N^2整除

ContractedBlock.gif ExpandedBlockStart.gif View Code

   
#include < iostream >
#include
< cstring >
using namespace std;
typedef
long long ll;
int p[ 100001 ] , tem[ 100001 ] ,t;
void Init()
{
memset(p,
0 , sizeof (p));
for (ll i = 2 ; i <= 100000 ; i ++ )
{
if ( ! p[i] )
{
for ( ll j = 2 ; j * i <= 100000 ; j ++ )
p[j
* i] = 1 ;
}
}
t
= 0 ;
for ( int i = 2 ;i < 1000000 ;i ++ )
{
if ( ! p[i])
{
tem[t
++ ] = i;
}
}
}
void Prime(ll n)
{

for ( int i = 0 ; i < t && tem[i] < n; i ++ )
{
if (n % tem[i] == 0 )
{`
cout
<< " YES " << endl;
return ;
}
}
cout
<< " NO " << endl;
}
int main()
{
ll n;
Init();
while (cin >> n)
{
if (n == 1 ) cout << " YES " << endl;
else if (n == 4 ) cout << " NO " << endl;
else Prime(n);
}
return 0 ;
}

转载于:https://www.cnblogs.com/FCWORLD/archive/2011/05/20/2052216.html

评论将由博主筛选后显示,对所有人可见 | 还能输入1000个字符 “速评一下”
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页