Encryption is the process of converting information algorithmically so that a valid recipient can read the information before it is no longer a valuable secret.
This is its validity period
. An attacker has limited processing power and can only test a certain number of keys per second.
This is the instruction count. The size of the universe of keys divided by the instruction count gives the average time to find a message key.
To achieve a balance between the processing power for encryption/ decryption and the strength of the encryption, the validity period of the message must be taken into consideration.
Given the number of keys, a hijacker can test per second, determine if the encrypted information should remain confidential throughout its validity period. Each test will return two items of information as integers:
The strength of the encryption is determined as follows:
keys[i]
, that act as keys.degree of divisibility
of an element is the number of elements in the set keys that are greater than 1
and are divisors of the element, i.e element modulo divisor = 0
.(the degree of divisibility of m)
* 10^5 Function Description
Complete the function encryptionValidity
.
encryptionValidity
has the following parameter(s):
int instructionCount
: the number of keys the hijacker can test per second int validityPeriod
: the number of seconds the message must be protected.int keys[n]
: the keys for encryption/decryptionExample 1:
Input: instructionCount = 1000, validityPeriod = 10000, keys = [2, 4, 8, 2]
Output: [1, 400000]
Explanation:The element m that has the maximum number of divisors is 8 ad its degree of divisibility is 4. The encryption strength is 4 * 10^5 = 400,000. The hijacker can perform instructionCount = 1,000 calculations per second. During the total validityPeriod = 10,000 seconds, the hijacker can test 1000 * 1000 = 1000000 = 10^7 keys. Thus, there is sufficient time for the key to be determined and the message decrypted before its validity expires. The first value in the return array is 1 because the message can be decrypted. The return array is [1, 400000] because the hijacker can decrypt the message in time, and the strength of the encryption is 400000.
1 <= instructionCount, validityPeriod <= 10^8
1 <= 1 <= n <= 105
1 <= 1<= keys[i] <= 105
input:
output: