Description
从键盘输入任意整数n,若n不是素数,则计算出n的所有因子(不包括1),例如对于16,输出2,4,8;否则输出“It is a prime number.”
判断素数和求因子分别用函数完成。
Input
任意整数n
Output
该数的因子或素数标志。
Sample Input
16
Sample Output
2
4
8
/* Copyrigh...
分类:
编程语言 时间:
2015-06-03 09:50:02
阅读次数:
136
Alexandra has a little brother. He is new to programming. One day he is solving the following problem: Given an positive integer N, judge whether N is...
分类:
其他好文 时间:
2015-06-03 09:35:30
阅读次数:
130
1 #include 2 #include 3 #include 4 using namespace std; 5 int main() 6 { 7 int i,n=0,m,a; 8 bool prime; 9 cin>>a;10 for(m=101;m<=2...
分类:
其他好文 时间:
2015-06-02 21:52:22
阅读次数:
111
1 #include 2 using namespace std; 3 int main() 4 { 5 int sushu(int x); 6 int a; 7 cin>>a; 8 if(sushu(a)==1) 9 cout<<"prime"<...
分类:
其他好文 时间:
2015-06-02 21:36:36
阅读次数:
79
又水,素数只能是连续的,而且最多才10000! 1 #include 2 3 using namespace std; 4 5 int a[10001]; 6 7 bool is_prime(int x) 8 { 9 if(x == 1) return 0;10 for...
分类:
其他好文 时间:
2015-06-02 21:25:09
阅读次数:
122
Prime Independence
Time Limit:3000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu
Submit Status Practice LightOJ
1356
Description
A set of integers is called prime independ...
分类:
其他好文 时间:
2015-06-02 00:28:05
阅读次数:
121
/*ID: awsd1231PROG: pprimeLANG: C++*/#include#includeusing namespace std;int mayAns[] = {5, 7, 11, 101, 131, 151, 181, 191, 313, 353, 373, 383, 727, 7...
分类:
其他好文 时间:
2015-05-31 15:13:35
阅读次数:
200
我们先来看一下最经典的埃拉特斯特尼筛法。时间复杂度为O(n loglog n)
int ans[MAXN];
void Prime(int n)
{
int cnt=0;
memset(prime,1,sizeof(prime));
prime[0]=prime[1]=0;
for(int i=2;i<n;i++)
{
if(vis[i])
{
ans[cnt++]=...
分类:
其他好文 时间:
2015-05-30 09:24:54
阅读次数:
277
Problem DescriptionA number whose only prime factors are 2,3,5 or 7 is called a humble number. The sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 15,...
分类:
其他好文 时间:
2015-05-29 20:14:10
阅读次数:
99
Semi-prime H-numbers
Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u
Submit Status Practice POJ
3292
Appoint description:
lijunle (2011-08-04)System Crawler (...
分类:
其他好文 时间:
2015-05-29 14:06:36
阅读次数:
202