Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 8c9e0ec

Browse files
Add files via upload
1 parent 94a85b4 commit 8c9e0ec

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

‎best_approach/power_of_two_no.cpp‎

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*
2+
written by Pankaj Kumar.
3+
country:-INDIA
4+
*/
5+
#include<algorithm>
6+
#include<string.h>
7+
#include<iostream>
8+
#include<vector>
9+
#include<deque>
10+
#include<cmath>
11+
#include<set>
12+
#include<map>
13+
using namespace std;
14+
typedef long long ll ;
15+
typedef vector<int> vi;
16+
typedef vector<pair<int,int>> vpi;
17+
typedef vector<ll> vl;
18+
typedef vector<pair<ll,ll>> vpl;
19+
typedef vector<string> vs;
20+
typedef set<string> ss;
21+
typedef set<int> si;
22+
typedef set<ll> sl;
23+
typedef set<pair<int,int>> spi;
24+
typedef set<pair<ll,ll>> spl;
25+
#define pan cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
26+
// define values.
27+
#define mod 1000000007;
28+
#define phi 1.618
29+
/* Bit-Stuff */
30+
#define get_set_bits(a) (__builtin_popcount(a))
31+
#define get_set_bitsll(a) ( __builtin_popcountll(a))
32+
#define get_trail_zero(a) (__builtin_ctz(a))
33+
#define get_lead_zero(a) (__builtin_clz(a))
34+
#define get_parity(a) (__builtin_parity(a))
35+
/* Abbrevations */
36+
#define ff first
37+
#define second ss
38+
#define mp make_pair
39+
#define line cout<<endl;
40+
#define pb push_back
41+
#define INT_SIZE sizeof(int)
42+
#define INT_BITS INT_SIZE*8-1
43+
/* ascii value
44+
A=65,Z=90,a=97,z=122
45+
*/
46+
/* -----------------------------------------------------------------------------------*/
47+
48+
// time complexity is O(log(n))
49+
int main()
50+
{
51+
pan;
52+
ll a,b,res=1;
53+
cout<<"Enter two no : ";
54+
cin>>a>>b;
55+
while(y>0)
56+
{
57+
if(y%2==1)
58+
res*=x;
59+
y=y/2;
60+
x=x*x;
61+
}
62+
cout<<res<<endl;
63+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /