Home
About
Contact
Privacy Policy
Programming Blog
Home
100 sql problem
UVA
Codeforces
LightOJ
Projects
Linux
Home
100 sql problem
UVA
Codeforces
LightOJ
Projects
Linux
Home
timus online judge
Timus online judge 1086 Cryptography
Timus online judge 1086 Cryptography
timus online judge
Zinnatul Islam Morol
Monday, September 17, 2018
A solution in c++
#include<bits/stdc++.h>
using namespace std;
/// Typedef
typedef long long int ll;
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0);
#define sc1(a) scanf("%lld",&a)
#define sc2(a,b) scanf("%lld %lld",&a,&b)
#define sc3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define pf1(a) printf("%lld\n",a)
#define pf2(a,b) printf("%lld %lld\n",a,b)
#define pf3(a,b,c) printf("%lld %lld %lld\n",a,b,c)
#define fr1(n) for(i=0;i<n;i++)
#define fr2(n) for(i=1;i<n;i++)
#define fr3(i,a,b) for(i=a;i<=b;i++)
/*primes in range 1 - n
1 - 100(1e2) -> 25 primes
1 - 1000(1e3) -> 168 primes
1 - 10000(1e4) -> 1229 primes
1 - 100000(1e5) -> 9592 primes
1 - 1000000(1e6) -> 78498 primes
1 - 10000000(1e7) -> 664579 primes
large primes ->
104729 1299709 15485863 179424673 2147483647 32416190071 112272535095293 48112959837082048697
*/
#define mx 1000005
#define mod 1000000007
vector<ll>vc;
vector<pair<ll, ll> >vcp,vcp2,vcx,vcy;
map<ll, ll>mp,mp2;
map<ll, ll>::iterator it,it2;
set<string>my1;
ll checkprime[mx];
vector<ll>prime;
void sieve()
{
ll n,i,j;
for(i=4; i<mx; i+=2) checkprime[i] = 1;
for(i=3; i*i<=mx; i+=2){
if(checkprime[i]==0){
for(j=i*i; j<mx; j+=(i+i))
checkprime[j] = 1;
}
}
for(i=2; i<mx; i++) if(!checkprime[i]) prime.push_back(i);
}
int main()
{
FastIO;
sieve();
ll n,m,i,j,k,ck=0,dk=0,a,b;
sc1(n);
while(n--){
sc1(a);
pf1(prime[a-1]);
}
}
Post a Comment
0 Comments
Followers
Search This Blog
Popular Posts
UVA 11172 - Relational Operator
Monday, January 22, 2018
Codeforces 4A Watermelon
Monday, January 22, 2018
UVA 12577 - Hajj-e-Akbar
Monday, January 22, 2018
বাংলা ভাষায় লেখা প্রোগ্রামিং এর সবচেয়ে বড় রিসোর্স কালেকশন
Saturday, September 08, 2018
Algorithm and programming Technique list (with relative links)
Saturday, September 08, 2018
Labels
100 sql problem
11
Binary Search
14
Dynamic Programming
26
ICPC Live Archive
16
Number Theory
72
codechef
16
codeforces
581
hackerrank
171
lightoj
60
math
146
uri
142
uva
209
Social Plugin
Buy Me A Coffee
0 Comments
If you have any doubts, Please let me know