Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
November 15, 2021 10:06 am GMT

Persistent Problem Statement : - Secret Key

Statement

Bob has to send a secret code 5 to his boss. He designs a method to encrypt the code using two key
values N and M. The formula that he uses to develop the encrypted code is shown below:

(((S^N % 10)^M)%1000000007)

Input Format

The input consists of an integer secretCode, representing the secret code (S).

The second line consists of an integer firstkey, representing the first key value (N)

The third line consists of an integer secondkey, representing the second key value (M).

Output

Print an integer representing thecode encrypted by Bob.

Example

Input:

234

Output:

4096

Explanation

S=2 , N=3 , M = 4 and the formula of the encrypted code is:
(((S^N % 10)^M)%1000000007)
((2^3 % 10)^3)%1000000007) = 4096

Solution

To edit the code click here

//secret key Persistentimport java.util.Scanner;import java.lang.Math;public class persistent2 {    public static int findSecretCode(int secretCode, int firstKey , int secondKey) {        int q= (int) Math.pow(secretCode,firstKey);        int w =q%10;        int e = (int) Math.pow(w,secondKey);    int res = e%1000000007;        return res;    }        public static void main(String args[])         {            Scanner in= new Scanner(System.in);            int secretCode = in.nextInt();            int firstKey =in.nextInt();            int secondKey = in.nextInt();    System.out.println(findSecretCode(secretCode,  firstKey , secondKey));        }    }

Original Link: https://dev.to/gouravmpk/persistent-problem-statement-secret-key-34pi

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To