Task 2. Development of a Method for Optimizing a Mathematical Problem

Problem Statement. At Unit 3 of an oil and gas company, the task is to optimize the operation of the navigation system elements. The task of this unit is to receive encrypted signals from Unit 1 and Unit 2, synthesize the incoming data packets, and further transmit them to the Data Processing Center. Write a program that receives one natural number from each unit as input, and returns a third number calculated by raising the value received from the first unit to the power of the number received from the second unit. Only the last digit of the resulting value will be sent to the Center. Use the following test values:

- From the first unit: 954950230952380948328708
- From the second unit: 470128749397540235934750230
Solution to the problem. Solving the problem "head-on" by raising one number to the power of another is bound to exceed the computational power not only of a single computer but even a data center would require a certain amount of time to perform the calculations. Since we only need to send the last digit, let's focus on calculating just that. Note that when raising numbers to a certain power, the last digit always has a certain cycle from a limited set of elements. For example: $2^{2}=4,2^{3}=8,2^{4}=16,2^{5}=32,2^{4}=64$.

Thus, we only need to take the last digit of the first number and the remainder of the second number divided by 4, and only then raise the first number to the power of the second.

Example of program implementation in Python

```
number = input()
degree = input()
number = int(str(number)[-1])
degree = int(str(degree)[-2] + str(degree)[-1]) % 4
if degree == 0:
    degree = 4
print((number ** degree))
```