【C++】OJ136

#include<iostream>
#include<vector>
#include<iterator>
#include<algorithm>
using namespace std;
bool ispri(long n){
	if(n<=3&&n>0)
		return false;
	for(int i = 2;i<=n/2;i++){
		if(n%i==0)
			return false;
	}
	return true;
}
int main(){
    long a = 0;
	long long i = 0;
	long b[1500];
	while(a<200){
		long u = 0;
		bool isug = true;
		long long s = i;
		long r[100];
		for(long k = 1;k<=i;k++){
			while(s%k==0&&k!=1){
				r[u++] = k;
				s /= k;
			}
		}
		for(long j = 0;j<u;j++){
		    if(r[j]!=2&&r[j]!=3&&r[j]!=5){
				isug = false;
				break;
			}
	    }
		if(isug==true&&ispri(i)==false){
			b[a++] = i;
		}
		i++;
	}
		for(int o = 0;o<1500;o++){
		    cout<<b[o]<<" ";
	   }
}

点赞