Find the total number of subsequences in an array whose elements are in GP with a common ratio of a prime number.
NOTE: The common ratio can by any prime number
Constraints:
1 <= array length = 10000
1 <= array elements <= 100000
.
Jim is at a position 0 and his grandma at X (given). Jim has to perform a round trip from his place (i.e., from 0) to his grandma's place (i.e., x), and return. In his route there are m resturants and n petrol pumps
(Their locations are given as arrays of m and n length respectively)
A Petrol pump can be visited multiple times, but a restaurant can be visited just once
That is, if you visit a restaurant while going to the position x, you can't visit it again while returning. But you can visit a petrol pump again.
You need to minimize the maximum distance Jim has to travel without stopping in one of the segments in his round trip.
(He can stop on petrol pumps and resturants for taking rest, and he chooses where to stop optimally)
Input:
int x, int m, int n
array r (of size m)
array p (of size n)Constrains:
r[i] <= x
p[i] <= x
output:
minimum value of the maximum distance he'd have to travel without stopping in the middle.
.
Alice has a favorite string and bob wants gift her a string 'SIMILAR' to her favorite string.
String A is similar to string B if, reversing exactly one substring of B makes it equal to A. (you can reverse any substring in B).
Find out the total number of string of the same length as alice's favorite string, which are similar to alice's favorite string.
Input:
int n -> denoting the size of alice's favorite string
string s -> Alice's favorite stringOutput:
The total number of strings of size n, which are similar to s (alice's favorite string)
Constrains:
1 <= n <= 100000