Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

a ^ b java

/*
  Given two non-negative integers a and b. Let's calculate a^b.
  If the result is too large, divide the remainder by 10^9 + 7.
*/
import java.util.Scanner;

public class EXC {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long res = 1;
        long mod = (long)1e9 + 7;
        while(b > 0){
          if ( b % 2 != 0) res = res * a % mod;
          a = a * a % mod;
          b >>= 1;
        }
        System.out.println(res);
    }
}
Comment

PREVIOUS NEXT
Code Example
Java :: Java Program to find the perimeter of the circle 
Java :: java float 
Java :: error: incompatible types: NonExistentClass cannot be converted to Annotation 
Java :: biginteger modulo in java 
Java :: java get class by string name 
Java :: connection data base java code 
Java :: ArrayIndexOutOfBoundsException 
Java :: int in string umwandeln 
Java :: client missing intents 
Java :: iptc classification java code example 
Java :: declare variable java 
Java :: bootstrap messages red 
Sql :: mysql reset auto increment value 
Sql :: select not matching data with join table 
Sql :: select all fields in soql 
Sql :: forgot my mysql password mac 
Sql :: oracle sql limit results 
Sql :: sql list all procedures 
Sql :: oracle enable job 
Sql :: how to add boolean column in postgresql 
Sql :: postgresql Insufficient privilege: 7 ERROR: permission denied for table 
Sql :: set mysql mode global query 
Sql :: sql dateadd hours 
Sql :: Row Number is sql server 
Sql :: find names starting with vowels in sql 
Sql :: oracle show running job 
Sql :: find a column in all tables postgres 
Sql :: import database in mysql command line xampp 
Sql :: mysql loop insert 
Sql :: connect python to mysql 
ADD CONTENT
Topic
Content
Source link
Name
8+3 =