Got to know about a new term today from Google, Wikipedia :-
Monday, October 31, 2022
Problem solved - XOR Equality
Hi. As I practice on various coding platforms, I keep on sharing my solutions as a blog post for me to refer back in future and also broadly for anyone searching for the same.
With this, let us begin with today's problem :-
Problem Name - XOR Equality
Problem Code - XOREQUAL
Problem Link - https://www.codechef.com/submit/XOREQUAL
How I solved it :-
Language used : C++
#include<iostream> using namespace std; #define m (int)(1e9+7) int poww(int base, int expo){ if(!expo) return 1; if(expo==1) return base%m; if(expo&1) return (1LL*(base%m)*(poww(base, expo-1)%m))%m; return poww((1LL*(base%m)*(base%m))%m, expo/2)%m; } void solve(void){ int n; cin>>n; cout<<poww(2, n-1)%m<<'\n'; return; } int main(void) { // your code goes here int t; cin>>t; while(t--) solve(); return 0; }
Subscribe to:
Posts (Atom)
You may like these:
HANDS ON JAVA(OOP - based uses) (Part-I)
Practice JAVA like Never Before! ...
-
Hey, 👲 you're probably here searching for the solution to an interestingly difficult task of counting the number of trailing ...
-
Hey, 👩 In the digital world, we represent numbers as binary bits (0's and 1's). Two such popular ways to represent ...
-
Hey, 💥😋 can you find the unique number in a list of duplicates ? It's an interesting interview question which has many sol...