diff --git a/codechef/moalp.cpp b/codechef/moalp.cpp new file mode 100644 index 0000000..2a46bae --- /dev/null +++ b/codechef/moalp.cpp @@ -0,0 +1,109 @@ +/************************************************************* + + Created by shivaank + +**************************************************************/ +#include +#include +using namespace std; +//keycode 87 = KP_End KP_1 KP_End KP_1 +typedef long long ll; +typedef vector vi; + +//#define x first +//#define y second + +typedef vector vll; +typedef pairii; +typedef pairmypair; +typedef vector vii; +typedef set sll; +typedef map msl; + +#define rep(i, a, b) \ +for (int i = int(a); i < int(b); i++) // a to b, and variable i is local! +#define TRvi(c, it) \ +for (vi::iterator it = (c).begin(); it != (c).end(); it++) +#define TRvii(c, it) \ +for (vii::iterator it = (c).begin(); it != (c).end(); it++) +#define TRmsi(c, it) \ +for (msi::iterator it = (c).begin(); it != (c).end(); it++) +#define INF 2000000000 // 2 billion +#define mod 1000000007 +#define mx 200001 + +string decToHexa(ll n) +{ + // char array to store hexadecimal number + string hexa; + + // counter for hexadecimal number array + + while(n!=0) + { + // temporary variable to store remainder + ll temp = 0; + + // storing remainder in temp variable. + temp = n % 16; + + // check if temp < 10 + if(temp < 10) + { + hexa += (temp + 48); + } + else + { + hexa += (temp + 55); + } + + n = n/16; + } + + // printing hexadecimal number array in reverse order + return hexa; +} + + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + ll t,n,k,ctr = 0,r, sum=1, m,flag = 0,x,y,a=0,b=0,c=0,d,ind,q,curr,ans=0,i,found,first; + + ll l; + string s,temp; + + unordered_mapmymap; + unordered_map ::iterator itr; + mymap[0] = 0; + std::stringstream stream; + for(int i = 1;i<=2000000;i++) + { + + s = decToHexa(i); + ctr = 0; + //cout<= 'A' && s[j]<='F') + ctr++; + } + mymap[i] = ctr; + if(i>1) + mymap[i] += mymap[i-1]; + //cout<>t; + while(t--) + { + cin>>l>>r; + + if(l == 1) + cout<