You are on page 1of 3

P1

You are playing a game called Innohit ; In which you are given a ball to hit a goal for a valid hit you
get coins ; for first valid hit you get 1; for every consecutive valid hits you win one extra coin from
previous one;
your task is to calculate what the maximum no. of coin you can win in n trails;

Input format:
first line t (1<= t <= 2*10^4) - no. of test cases.
For each test case there is n (1<=n<=10^8) which no of trails

Output:
print maximum for of coin he can win in n trails

Sample Test case:


5
1
4
7
10
2

1
10
28
55
3

P2
You are playing a game, called InnoCraft; In which you have to make K magical wands made by using
obsidian and iron rod.
There are instructions to a make magicial wand:
1. One magical wand can be formed by one iron rod and one obsidian.
2: You know a magical spell by which you can do following operations:
1. You can convert 1 iron rod to x iron rod
2. You can convert y iron rod to 1 obsidian
In one spell you can perform one of these operation.

Intially you have one iron rod you have make k magical wands.
Your task is to find minimum no. spell you have to perform to make k magical wands.

Input format :
first line t (1<= t <= 2*10^4) - no. of test cases.
The only line of the test case contains three integers x, y and k (2≤x≤10^9; 1≤y,k≤10^9) - no. iron
wonds you can convert from one iron rod,the no of iron rod required to convert in one obsidian, no. of
magical wands you have to form;

Output:
You have to print no. of spells required to form k magical wands for each test case;
Sample Test case;
Input:
3
327
15 6 24
40 19 23

OutPut:
17
36
35

P2

You are playing a game called InnoWord in which you provide with two string contains lowercase
letters s1,s2;
you have to form string to s2 from s1 by s1 appending multiple times , you can erase any character
from string obtained by appending s1;
You task is find what is minimum no. of time you have to append string s1 to get s2;

eg:
s1=”abcd”
s2=”dabc”
if you append s1 two times string becomes “abcdabcd” if erase “abc” from starting and “d” from end
you get strign “dabc” hence in two append you find the s2;
So, you have print 2; if it is impossible to do print -1;

Input format:
s1 (1<=len(s1)<=10^4)
s2 (1<=len(s2)<=10^6)

Output:
Print no. of times you have append string s1 to get s2 by using above instructions;

Sample Test case:


test case1:
abc
xyz

-1

test case 2:

abcd
dabc
2

P4

You are given an array a consisting of n integers.


You have to perform the sequence of n−2 operations on this array:
• during the first operation, you either add a2 to a1 and subtract a2 from a3, or add a2 to a3 and
subtract a2 from a1;
• during the second operation, you either add a3 to a2 and subtract a3 from a4, or add a3 to a4 and
subtract a3 from a2;
• ...
• during the last operation, you either add an−1 to an−2 and subtract an−1 from an, or add an−1 to an and
subtract an−1 from an−2.
So, during the i-th operation, you add the value of ai+1 to one of its neighbors, and subtract it from the
other neighbor.
For example, if you have the array [1,2,3,4,5], one of the possible sequences of operations is:
• subtract 2 from a3 and add it to a1, so the array becomes [3,2,1,4,5];
• subtract 1 from a2 and add it to a4, so the array becomes [3,1,1,5,5];
• subtract 5 from a3 and add it to a5, so the array becomes [3,1,−4,5,10].
So, the resulting array is [3,1,−4,5,10].
An array is reachable if it can be obtained by performing the aforementioned sequence of operations
on a. You have to calculate the number of reachable arrays, and print it modulo 998244353.
Input
The first line contains one integer n (3≤n≤300).
The second line contains n integers a1,a2,…,an (0≤ai≤300).
Output
Print one integer — the number of reachable arrays. Since the answer can be very large, print its
remainder modulo 998244353

You might also like