BITWISE TUPLES (BITTUP) Solution — Codechef JuneLong Challenge

Input

  • The first line contains a single integer T denoting the number of test cases. The description of T test cases follows.
  • The first and only line of each test case contains two integers N and M.

Output

Constraints

  • 1≤T≤10⁵
  • 1≤N,M≤10⁶

Subtasks

Sample Input

4
1 2
2 2
4 2
8 4

Sample Output

1
9
225
228250597

Explanation

/* package codechef; // don't place package name! */import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
static long mod = 1000000007;
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while(t-- > 0){
long a=0,b=0;
a = sc.nextLong();
b = sc.nextLong();
long ians = findPower(2, a)-1;
System.out.println(findPower(ians,b));
}
}

public static long findPower(long a , long b){
if(b==0)
return 1;
else if(b==1)
return a;

if((b%2)==0){
long temp = findPower(a,b/2);
return (temp*temp)%mod;
}
else{
long temp = findPower(a,(b-1)/2);
return ((a*temp)%mod*temp)%mod;
}
}
}

--

--

--

Software Developer ,currently pursuing B.Tech in Information Technology. Electronic Dance Music is love.Also like all phone related technologies

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Haskell Open Source, 2022

Image of several computer screens with a hooded man in the foreground

Important Of Defining: Functional Requirements Vs. Non-functional Requirements

Lp To Mps Converter For Mac

Everyone can Wiki — online meeting provides practical hands-on experience

Setting Gitlab CI/CD for Python application

4D Result Live — How to Win a Damacai 4D Lottery?

4D Result Live - How to Win a Damacai 4D Lottery?

HTML Progress Bar with CSS-only Dynamic Labels

Configuring Web Server and Designing High Availability CloudFront Distribution Using AWS CLI.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Anubhav Mishra

Anubhav Mishra

Software Developer ,currently pursuing B.Tech in Information Technology. Electronic Dance Music is love.Also like all phone related technologies

More from Medium

How Works Object Creation ?

Class and Object

Remove Zero Sum Consecutive Nodes from Linked List

Java static can be…