标签:
Distinct Primes42
#include<stdio.h> #include<string.h> int p[10000]; int a[10000]; int lucky(int x){ int num=0,i=2; while(x>1){ if(x%i==0){ num++; while(x%i==0) x/=i; }else{ i++; while(p[i]){ i++; } } } if(num>=3) return 1; return 0; } void sloved(){ int i=0; int x=30; while(i<=1500){ if(lucky(x)){ a[++i]=x; } x++; } } int main(){ int i,j; memset(p,0,sizeof(p)); p[0]=p[1]=1; for(int i=2;i*i<10000;i++){ if(!p[i]){ for(int j=i*i;j<10000;j+=i){ p[j]=1; } } } sloved(); int t,n; scanf("%d",&t); while(t--){ scanf("%d",&n); printf("%d\n",a[n]); } return 0; }
spoj 10232 Distinct Primes(打表)
标签:
原文地址:http://blog.csdn.net/ling_du/article/details/47779877