This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int main() | |
{ | |
int n, cnt = 0; | |
cin >> n; | |
while(n) | |
{ | |
n &= (n-1); | |
cnt++; | |
} | |
cout << cnt <<endl; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void primeFactors(int n) | |
{ | |
// Print the number of 2s that divide n | |
while (n%2 == 0) | |
{ | |
printf("%d ", 2); | |
n = n/2; | |
} | |
// n must be odd at this point. So we can skip one element (Note i = i +2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void multiply(char a[], char b[], char res[]) | |
{ | |
int i, j, k, mul, carry; | |
// if one number is zero, then result obviously zero | |
if(strcmp(a, "0") == 0 || strcmp(b, "0") == 0) | |
{ | |
strcpy(res, "0"); | |
return; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits//stdc++.h> | |
using namespace std; | |
#define MP make_pair | |
#define PB push_back | |
#define INF (int)1e9 | |
#define EPS 1e-9 | |
#define PI 3.1415926535897932384626433832795 | |
#define MOD 1000000007 |
NewerOlder