Posts

Showing posts from May, 2020

ALL Number product resulted number divisor count

Problem:  https://acm.timus.ru/problem.aspx?space=1&num=1049 # include <bits/stdc++.h> using namespace std ; typedef long long ll; # define fast ios_base:: sync_with_stdio( false ); cin.tie(0); cout.tie(0); int status[ 100000000 / 32 ]; bool Check ( int N, int pos) { return ( bool )(N & ( 1 <<pos));} int Set ( int N, int pos) { return N=N | ( 1 <<pos);} long long int arr[ 10000000 ]; long long int l= 0 ,a,b= 100000 ,n; void sieve () { long long int i,j,sqrtN; sqrtN = int ( sqrt ( b ) ); for ( i= 3 ; i<=sqrtN; i+= 2 ) { if ( Check(status[i/ 32 ],i% 32 )== 0 ) { for (j=i*i; j<=b; j+= 2 *i) { status[j/ 32 ]=Set(status[j/ 32 ],j% 32 ); } } } arr[ 0 ]= 2 ; l= 1 ; for (i= 3 ;i<=b;i+= 2 ) { if (Check(status[i/ 32 ],i% 32 )== 0 ) { arr[l]=i; l++; } } } long lo...

UVA 10004

#include<bits/stdc++.h> #define rep0(i,n) for(i=0;i<n;i++) #define rep(i,n) for(i=1;i<=n;i++) #define reps(i,a,n) for(i=a;i<=n;i++) #define mem(ara,n) memset(ara,n,sizeof(ara)) #define memb(ara) memset(ara,false,sizeof(ara)) #define all(x) (x).begin(),(x).end() #define fast ios_base:: sync_with_stdio( false ); cin.tie(0); cout.tie(0); #define eb              emplace_back #define em              emplace #define pb              push_back #define Mp              make_pair #define ff              first #define ss              second #define mod 1000000007 typedef long long ll; using namespace std; const int M = (int)(2e6 + 239); void decitobinbitodeci() {     string binary = bitset<8>(128).to_string(); //to binary     cou...