To solve this problem, the main task is to calculate the income of Ator in any month. As we know the first salary x, the increasing difference of the income of two consecutive months and the value of n, we can calculate the salary of the nth month using a for loop. But as the upper limit of n is 10^9, we cannot use any loop within the given time limit. Rather, we need to calculate the income of the month in constant time. It can be done by using the concept of Arithmetic Series.

According to Wikipedia, an arithmetic progression or arithmetic sequence is a sequence of numbers such that the difference between the consecutive terms is constant. For instance, the sequence 5, 7, 9, 11, 13, 15 is an arithmetic progression with a common difference of 2.

If the initial term of an arithmetic progression is a1, and the common difference of successive members is d, then the n-th term of the sequence is given by:

an = a1 + (n-1) * d

In this problem,we can see that the common difference of the salary of every month is constant. So we can apply the formula in this problem to get the nth term.

Statistics

89% Solution Ratio
Siddik_53rdEarliest, Nov '21
Kuddus.6068Fastest, 0.1s
nusuBotLightest, 4.9 MB
Nusab19Shortest, 98B
Toph uses cookies. By continuing you agree to our Cookie Policy.