title: Modular Exponentiation Power In Modular Arithmetic
signature: class Solution {
  
      public Integer modularExponentiationPowerInModularArithmetic(Integer x, Integer y, Integer p) {
source_py: def modular_exponentiation_power_in_modular_arithmetic(x, y, p):
      res = 1
      x = (x % p)
      while (y > 0):
          if ((y & 1) == 1):
              res = ((res * x) % p)
          y = (y >> 1)
          x = ((x * x) % p)
      return res
source_cpp: int modular_exponentiation_power_in_modular_arithmetic(int x, unsigned int y, int p) {
    int res = 1;
    x = x % p;
    while ( y > 0 ) {
      if ( y & 1 ) res = ( res * x ) % p;
      y = y >> 1;
      x = ( x * x ) % p;
    }
    return res;
  }
question_info.extension: java
question_info.entry_fn_name: modularExponentiationPowerInModularArithmetic
question_info.entry_cls_name: Solution
question_info.test_list: [{"idx": 0, "outputs": 61, "inputs": {"x": 45, "y": 5, "p": 68}}, {"idx": 1, "outputs": 18, "inputs": {"x": 67, "y": 25, "p": 49}}, {"idx": 2, "outputs": 4, "inputs": {"x": 26, "y": 91, "p": 44}}, {"idx": 3, "outputs": 0, "inputs": {"x": 33, "y": 61, "p": 9}}, {"idx": 4, "outputs": 3, "inputs": {"x": 35, "y": 8, "p": 13}}, {"idx": 5, "outputs": 3, "inputs": {"x": 68, "y": 41, "p": 5}}, {"idx": 6, "outputs": 16, "inputs": {"x": 14, "y": 76, "p": 20}}, {"idx": 7, "outputs": 5, "inputs": {"x": 5, "y": 89, "p": 13}}, {"idx": 8, "outputs": 19, "inputs": {"x": 23, "y": 42, "p": 45}}, {"idx": 9, "outputs": 29, "inputs": {"x": 37, "y": 63, "p": 56}}]
question_info.test_code: import static java.util.Map.entry;  
  import java.util.*;
  import java.lang.*;
  // TESTING CODE 
  // ============================================
  class QuestionEvaluator {
      public static String validateSolution(Integer x, Integer y, Integer p, Integer expected){
          try{
              Driver driver = new Driver();
              if (driver.run(x, y, p,expected)){
                  return "PASSED";
              }
              return "FAILED";
              
          } catch (Exception exception_obj){
              return exception_obj.getClass().getSimpleName();
          }
  
      }
      public static void main(String[] args) {
          String result;
          result = validateSolution(45, 5, 68, 61);
          System.out.println(String.format("%s%s","TEST-0...",result));    
      
          result = validateSolution(67, 25, 49, 18);
          System.out.println(String.format("%s%s","TEST-1...",result));    
      
          result = validateSolution(26, 91, 44, 4);
          System.out.println(String.format("%s%s","TEST-2...",result));    
      
          result = validateSolution(33, 61, 9, 0);
          System.out.println(String.format("%s%s","TEST-3...",result));    
      
          result = validateSolution(35, 8, 13, 3);
          System.out.println(String.format("%s%s","TEST-4...",result));    
      
          result = validateSolution(68, 41, 5, 3);
          System.out.println(String.format("%s%s","TEST-5...",result));    
      
          result = validateSolution(14, 76, 20, 16);
          System.out.println(String.format("%s%s","TEST-6...",result));    
      
          result = validateSolution(5, 89, 13, 5);
          System.out.println(String.format("%s%s","TEST-7...",result));    
      
          result = validateSolution(23, 42, 45, 19);
          System.out.println(String.format("%s%s","TEST-8...",result));    
      
          result = validateSolution(37, 63, 56, 29);
          System.out.println(String.format("%s%s","TEST-9...",result));    
      
      }
  }
  
  class Driver{
      public boolean run(Integer x, Integer y, Integer p, Integer expected){
  
          PLACEHOLDER_CLS_NAME sol = new PLACEHOLDER_CLS_NAME();
          return validateSolution(sol.PLACEHOLDER_FN_NAME(x, y, p),expected);
      }
      
      public boolean validateSolution(Integer actual, Integer expected){
          return actual.equals(expected);
      }
  }
  
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
question_info.test_case_ids: 0 1 2 3 4 5 6 7 8 9
question_info.commands: java __FILENAME__