摘要:
筛选法应用!先来最基本的线性筛素数,以后的算法其实都是基于这个最基本的算法:1#include<stdio.h>2#include<string.h>3#defineM100000004intprime[M/3];5boolflag[M];6voidget_prime()7{8inti,j,k;9memset(flag,false,sizeof(flag));10k=0;11for(i=2;i<M;i++){12if(!flag[i])13 prime[k++]=i;14for(j=0;j<k&&i*prime[j]<M;j++){15 阅读全文
摘要:
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, 16, 18, 20, 21, 24, 25, 27, ... shows the first 20 humble numbers.Write a program to find and print the nth element in this sequenceInputThe input co 阅读全文