Skip to content

Commit d00b41b

Browse files
authored
Merge pull request ephremdeme#174 from Pankajcoder1/all-contributors/add-Pankajcoder1
All contributors/add pankajcoder1
2 parents 150458a + 1e3632a commit d00b41b

File tree

5 files changed

+294
-0
lines changed

5 files changed

+294
-0
lines changed
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
/*
2+
written by Pankaj Kumar.
3+
country:-INDIA
4+
*/
5+
#include <bits/stdc++.h>
6+
using namespace std;
7+
// policy based ds
8+
#include<ext/pb_ds/assoc_container.hpp>
9+
#include<ext/pb_ds/tree_policy.hpp>
10+
using namespace __gnu_pbds;
11+
typedef long long ll ;
12+
typedef vector<ll> vl;
13+
typedef vector<bool> vb;
14+
typedef vector<char> vc;
15+
typedef map<ll,ll> ml;
16+
#define pan cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
17+
// define values.
18+
#define mod 10000009
19+
#define phi 1.618
20+
/* Bit-Stuff */
21+
#define get_set_bits(a) (__builtin_popcount(a))
22+
#define get_set_bitsll(a) ( __builtin_popcountll(a))
23+
#define get_trail_zero(a) (__builtin_ctz(a))
24+
#define get_lead_zero(a) (__builtin_clz(a))
25+
#define get_parity(a) (__builtin_parity(a))
26+
/* Abbrevations */
27+
#define ff first
28+
#define ss second
29+
#define mp make_pair
30+
#define line cout<<endl;
31+
#define pb push_back
32+
#define Endl "\n"
33+
// loops
34+
#define forin(arr,n) for(ll i=0;i<n;i++) cin>>arr[i];
35+
// Some print
36+
#define no cout<<"NO"<<endl;
37+
#define yes cout<<"YES"<<endl;
38+
#define cc ll test;cin>>test;while(test--)
39+
// sort
40+
#define all(V) (V).begin(),(V).end()
41+
#define srt(V) sort(all(V))
42+
#define srtGreat(V) sort(all(V),greater<ll>())
43+
// function
44+
45+
ll power(ll x,ll y)
46+
{
47+
ll res=1;
48+
// x=x%mod;
49+
while(y>0)
50+
{
51+
if(y%2==1)
52+
{
53+
res*=x;
54+
// res=res%mod;
55+
}
56+
y/=2; x*=x; // x=x%mod;
57+
}
58+
return res;
59+
}
60+
// datatype definination
61+
#define ordered_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
62+
63+
/* ascii value
64+
A=65,Z=90,a=97,z=122
65+
*/
66+
/* -----------------------------------------------------------------------------------*/
67+
68+
// time complexity of this algorithm is O(logn)
69+
const int MAX = 1000;
70+
int f[MAX] = {0};
71+
72+
int fib(ll n)
73+
{
74+
if (n == 0)
75+
return 0;
76+
if (n == 1 || n == 2)
77+
return (f[n] = 1);
78+
if (f[n])
79+
return f[n];
80+
81+
ll k = (n & 1)? (n+1)/2 : n/2;
82+
f[n] = (n & 1)? (fib(k)*fib(k) + fib(k-1)*fib(k-1))
83+
: (2*fib(k-1) + fib(k))*fib(k);
84+
85+
return f[n];
86+
}
87+
88+
int main()
89+
{
90+
ll n;
91+
cin>>n;
92+
cout<<ll(fib(n))<<endl;
93+
return 0;
94+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// time complexity of this algo is sqrt(n);
2+
/*
3+
written by pankaj kumar.
4+
*/
5+
#include<algorithm>
6+
#include<string.h>
7+
#include<iostream>
8+
#include<vector>
9+
#include<cmath>
10+
#include<set>
11+
using namespace std;
12+
typedef long long ll ;
13+
typedef vector<int> vi;
14+
typedef vector<pair<int,int>> vpi;
15+
typedef vector<ll> vl;
16+
typedef vector<pair<ll,ll>> vpl;
17+
typedef vector<string> vs;
18+
typedef set<string> ss;
19+
typedef set<int> si;
20+
typedef set<ll> sl;
21+
typedef set<pair<int,int>> spi;
22+
typedef set<pair<ll,ll>> spl;
23+
// macros
24+
#define pan cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
25+
#define mod 1000000007;
26+
#define phi 1.618
27+
#define line cout<<endl;
28+
/* ascii value
29+
A=65,Z=90,a=97,z=122
30+
*/
31+
32+
int main()
33+
{
34+
int a,count=0;
35+
cout<<"Enter two number : ";
36+
cin>>a;
37+
cout<<"List of all factor of "<<a<<"is : ";
38+
for(int i=1;i<=sqrt(a);i++)
39+
{
40+
if(a%i==0)
41+
{
42+
if(a/i==i)
43+
{
44+
count++;
45+
cout<<i<<" ";
46+
}
47+
else
48+
{
49+
count+=2;
50+
cout<<a/i<<" "<<i<<" ";
51+
}
52+
}
53+
}
54+
line;
55+
cout<<"Hence total no of factor of "<<a<<" is "<<count<<endl;
56+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
written by Pankaj Kumar.
3+
country:-INDIA
4+
*/
5+
#include<bits/stdc++.h>
6+
using namespace std;
7+
typedef long long ll ;
8+
typedef vector<int> vi;
9+
typedef vector<pair<int,int>> vpi;
10+
typedef vector<ll> vl;
11+
typedef vector<pair<ll,ll>> vpl;
12+
typedef vector<string> vs;
13+
typedef set<string> ss;
14+
typedef set<int> si;
15+
typedef set<ll> sl;
16+
typedef set<pair<int,int>> spi;
17+
typedef set<pair<ll,ll>> spl;
18+
#define pan cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
19+
// define values.
20+
#define mod 1000000007;
21+
#define phi 1.618
22+
/* Bit-Stuff */
23+
#define get_set_bits(a) (__builtin_popcount(a))
24+
#define get_set_bitsll(a) ( __builtin_popcountll(a))
25+
#define get_trail_zero(a) (__builtin_ctz(a))
26+
#define get_lead_zero(a) (__builtin_clz(a))
27+
#define get_parity(a) (__builtin_parity(a))
28+
/* Abbrevations */
29+
#define ff first
30+
#define second ss
31+
#define mp make_pair
32+
#define line cout<<endl;
33+
#define pb push_back
34+
#define INT_SIZE sizeof(int)
35+
#define INT_BITS INT_SIZE*8-1
36+
/* ascii value
37+
A=65,Z=90,a=97,z=122
38+
*/
39+
/* -----------------------------------------------------------------------------------*/
40+
41+
// time complexity is O(log(n))
42+
int main()
43+
{
44+
pan;
45+
ll a,b,res=1;
46+
cout<<"Enter two no : ";
47+
cin>>a>>b;
48+
while(b>0)
49+
{
50+
if(b%2==1)
51+
res*=a;
52+
b=b/2;
53+
a=a*a;
54+
}
55+
cout<<res<<endl;
56+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
/*
2+
written by Pankaj Kumar.
3+
country:-INDIA
4+
*/
5+
#include <bits/stdc++.h>
6+
using namespace std;
7+
typedef long long ll ;
8+
typedef set<pair<int,int>> spi;
9+
typedef set<pair<ll,ll>> spl;
10+
typedef vector<pair<int,int>> vpi;
11+
typedef vector<int> vi;
12+
typedef vector<ll> vl;
13+
typedef vector<bool> vb;
14+
typedef vector<char> vc;
15+
typedef vector<pair<ll,ll>> vpl;
16+
typedef vector<string> vs;
17+
typedef map<int,int>mi;
18+
typedef map<ll,ll> ml;
19+
typedef set<string> ss;
20+
typedef set<char>sc;
21+
typedef set<int> si;
22+
typedef set<ll> sl;
23+
#define pan cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
24+
// define values.
25+
#define mod 1000000007
26+
#define phi 1.618
27+
/* Bit-Stuff */
28+
#define get_set_bits(a) (__builtin_popcount(a))
29+
#define get_set_bitsll(a) ( __builtin_popcountll(a))
30+
#define get_trail_zero(a) (__builtin_ctz(a))
31+
#define get_lead_zero(a) (__builtin_clz(a))
32+
#define get_parity(a) (__builtin_parity(a))
33+
/* Abbrevations */
34+
#define ff first
35+
#define ss second
36+
#define mp make_pair
37+
#define line cout<<endl;
38+
#define pb push_back
39+
#define Endl "\n"
40+
// loops
41+
#define loop(i,start,end) for(ll i=ll(start);i<ll(end);i++)
42+
#define loop0(num) for(ll i=0;i<ll(num);i++)
43+
#define forin(arr,n) for(ll i=0;i<n;i++) cin>>arr[i];
44+
// Some print
45+
#define no cout<<"NO"<<endl;
46+
#define yes cout<<"YES"<<endl;
47+
#define cc ll test;cin>>test;while(test--)
48+
// sort
49+
#define all(V) (V).begin(),(V).end()
50+
#define srt(V) sort(all(V))
51+
#define srtGreat(V) sort(all(V),greater<ll>())
52+
// function
53+
54+
ll power(ll x,ll y)
55+
{
56+
ll res=1;
57+
while(y>0)
58+
{
59+
if(y%2==1)res*=x;
60+
y/=2; x*=x;
61+
}
62+
return res;
63+
}
64+
/* ascii value
65+
A=65,Z=90,a=97,z=122
66+
*/
67+
/* -----------------------------------------------------------------------------------*/
68+
69+
70+
int main()
71+
{
72+
ll n;
73+
cin>>n;
74+
vl v(n,0);
75+
forin(v,n);
76+
ll total=1<<n;
77+
loop(i,0,total)
78+
{
79+
ll sum=0;
80+
loop(j,0,n)
81+
{
82+
if(i&(1<<j))
83+
sum+=v[j];
84+
}
85+
cout<<"sum is "<<sum<<endl;
86+
}
87+
}

0 commit comments

Comments
 (0)