Skip to content

Commit f573fec

Browse files
authored
Add files via upload
1 parent 37f9d34 commit f573fec

File tree

1 file changed

+125
-0
lines changed

1 file changed

+125
-0
lines changed
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
/*
2+
written by Pankaj Kumar.
3+
country:-INDIA
4+
*/
5+
#include <bits/stdc++.h>
6+
#include <ext/pb_ds/assoc_container.hpp>
7+
#include <ext/pb_ds/tree_policy.hpp>
8+
using namespace std;
9+
using namespace __gnu_pbds;
10+
typedef long long ll ;
11+
typedef vector<ll> vl;
12+
#define speed cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
13+
// define values.
14+
// #define mod 1000000007
15+
#define phi 1.618
16+
/* Abbrevations */
17+
#define ff first
18+
#define ss second
19+
#define mp make_pair
20+
#define line cout<<endl;
21+
#define pb push_back
22+
#define Endl "\n"
23+
// loops
24+
#define forin(arr,n) for(ll i=0;i<n;i++) cin>>arr[i];
25+
// Some print
26+
#define no cout<<"NO"<<endl;
27+
#define yes cout<<"YES"<<endl;
28+
// sort
29+
#define all(V) (V).begin(),(V).end()
30+
#define srt(V) sort(all(V))
31+
#define srtGreat(V) sort(all(V),greater<ll>())
32+
#define printv(v) for(ll i=0;i<ll(v.size());i++){cout<<v[i]<<" ";} line;
33+
// some extra
34+
#define sz(V) ll(V.size())
35+
/* ONLINE JUDGE */
36+
// #ifdef ONLINE_JUDGE
37+
// freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
38+
// #endif
39+
// template
40+
template <typename T>
41+
T mymax(T x,T y)
42+
{
43+
return (x>y)?x:y;
44+
}
45+
// function
46+
47+
ll power(ll x,ll y,ll mod)
48+
{
49+
ll res=1;
50+
// x=x%mod;
51+
while(y>0)
52+
{
53+
if(y%2==1)
54+
{
55+
res*=x;
56+
// res=res%mod;
57+
}
58+
y/=2; x*=x; // x=x%mod;
59+
}
60+
return res;
61+
}
62+
ll str_to_num(string s)
63+
{
64+
return stoi(s);
65+
}
66+
67+
string num_to_str(ll num)
68+
{
69+
return to_string(num);
70+
}
71+
// datatype definination
72+
#define ordered_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
73+
74+
/* ascii value
75+
A=65,Z=90,a=97,z=122
76+
*/
77+
/* -----------------------------------------------------------------------------------*/
78+
79+
ll solve()
80+
{
81+
ll n;
82+
cin>>n;
83+
vl v(n+1.0);
84+
vl prime;
85+
for(ll i=2;i<=n;i++)
86+
{
87+
if(v[i]==0)
88+
{
89+
v[i]=i;
90+
prime.pb(i);
91+
}
92+
for(ll j=0;j<sz(prime)&&prime[j]<=v[i]&&(i*prime[j])<=n;j++)
93+
{
94+
v[i*prime[j]]=prime[j];
95+
}
96+
}
97+
for(ll i=2;i<=n;i++)
98+
{
99+
if(v[i]==i)
100+
{
101+
cout<<i<<" ";
102+
}
103+
}
104+
line;
105+
return 0;
106+
}
107+
108+
int main()
109+
{
110+
speed;
111+
// freopen("input.txt","r",stdin);
112+
// freopen("output.txt","w",stdout);
113+
ll TestCase=1;
114+
// cin>>TestCase;
115+
while(TestCase--)
116+
{
117+
solve();
118+
}
119+
}
120+
121+
/* stuff you should look before submission
122+
* int overflow
123+
* special test case (n=0||n=1||n=2)
124+
* don't get stuck on one approach if you get wrong answer
125+
*/

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy