Skip to content

Commit b52078a

Browse files
committed
feb circuits
1 parent 4d17ce3 commit b52078a

18 files changed

+2245
-0
lines changed

Codechef/practice/BMI.cpp

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

Codechef/practice/CHEFPAT.cpp

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

Codechef/practice/ENGXOR.cpp

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

0 commit comments

Comments
 (0)