标签:mem namespace center prime margin pac inpu please title
Time Limit:1s Memory Limit:128MByte
Given a number sequence [3,7,22,45,116,...]
. Please tell me the k
-th number.
indicates the number of the input cases. Then for each case there only is one integer k (1≤k≤10000)
#include <iostream> #include <cstdio> #include <cstring> #include <queue> #include <cmath> #include <vector> #include <algorithm> using namespace std; #define lowbit(x) (x&(-x)) #define max(x,y) (x>y?x:y) #define min(x,y) (x<y?x:y) #define mem(a) (memset(a,0,sizeof(a))) typedef long long ll; ll a[105000]; ll vis[10006]; void getprime() { memset(a,0,sizeof(a)); a[1]=1; for(ll i=2;i<105000;i++) { if(a[i]==1) continue; for(ll j=2;j*i<105000;j++) a[j*i]=1; } ll ans=1; for(ll i=2;i<105000;i++) { if(!a[i]) vis[ans++]=i; if(ans>=10002) break; } } int main() { ll t,n; scanf("%lld",&t); getprime(); while(t--) { scanf("%lld",&n); printf("%lld\n", vis[n]*vis[n]-n); } }
标签:mem namespace center prime margin pac inpu please title
原文地址:http://www.cnblogs.com/shinianhuanniyijuhaojiubujian/p/7182233.html