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
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
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
int countSetBits(unsigned int n) | |
{ | |
unsigned int count = 0; | |
while(n) | |
{ | |
count += n & 1; // ভাগশেষ ০ নাকি ১ । যদি ১ হয় তাহলে কাউন্টের মান বেড়ে যাবে । | |
n >>= 1; // n কে দুই দিয়ে ভাগ করা হচ্ছে । | |
} | |
return count; | |
} |
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
ll totient (ll i) | |
{ | |
ll res; /* Result */ | |
ll j; | |
if (i==1) return 1; | |
res=i; | |
// Check for divisibility by every prime number below the square root. |
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
bool isPrime(int n) { | |
if(n < 2) return false; | |
for(int i = 2; i < sqrt(n); i++) | |
if(n%i == 0) return false; | |
} |
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
#define MAX 1000001 | |
char prime[MAX]; // 0 দিয়ে initialize করতে হবে | |
void seive( int n ) // n পর্যন্ত প্রাইম বের করব | |
{ | |
int x = sqrt( n ); | |
prime[0] = prime[1] = 1; // 0 এবং 1 প্রাইম না | |
for( int i = 4; i <= n; i += 2 ) // জোড় সংখ্যাগুলোকে বাদ দিয়ে দিব | |
prime[i] = 1; |
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; | |
scanf("%d", &n); | |
map<string, int>mp; | |
for(int i=0; i<n; i++){ | |
string s; | |
cin>>s; | |
if(mp[s] == 0) {mp[s]++; printf("OK\n");} | |
else { |
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; | |
int a[10000]; | |
int m, n, x, temp, sum, i, j; | |
int main() | |
{ | |
while(scanf("%d", &n)==1){ | |
a[0] = 1; |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
OlderNewer