ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1086. Cryptography

AC in 0.015
Posted by Aditya Singh 15 Apr 2017 05:35
#include<bits/stdc++.h>
using namespace std;
bool B[164009];
vector<long> V;
void prime()
{
    for(long i=2;i<=405;i++)
        if(B[i]==0)
            for(long j=2;i*j<=164000;j++)
                B[i*j]=1;
    for(long i=2;i<=164000;i++)
        if(B[i]==0)
            V.push_back(i);

}
int main()
{
    ifstream cin("input.in");
    ofstream cout("output.out");
    ios::sync_with_stdio(0);cin.tie(0);
    prime();
    long T;
    cin>>T;
    while(T--)
    {
        long N;
        cin>>N;
        cout<<V[N-1]<<"\n";
    }
    //for(vector<long>::iterator it=V.begin();it!=V.end();it++)
    //    cout<<*it<<"\n";
}
Re: AC in 0.015
Posted by shammya 24 Oct 2018 03:23
great code.i learned a lot from this.