C Programs PDF
C Programs PDF
Fibonacci String
For a string SS let the unique set of characters that occur in it one or
more times be CC. Consider a permutation of the elements
of CC as (c1,c2,c3...)(c1,c2,c3...). Let f(c)f(c) be the number of
times cc occurs in SS.
If any such permutation of the elements
of CC satisfies f(ci)=f(ci−1)+f(ci−2)f(ci)=f(ci−1)+f(ci−2) the string is
said to be a dynamic string.
Mr Bancroft is given the task to check if the string is dynamic, but he
is busy playing with sandpaper. Would you help him in such a state?
Input:
• First line will contain TT, number of testcases. Then the testcases
follow.
• Each testcase contains of a single line of input, a string SS.
Output:
For each testcase, output in a single line "Dynamic" if the given string
is dynamic, otherwise print "Not". (Note that the judge is case
sensitive)
________________________________________________________
Constraints
• 1≤T≤10
• 1≤|S|≤10
• SS contains only lower case alphabets: aa, bb, …, z
Sample Input:
aaaabccc
aabbcc
Sample Output:
Dynamic
Not
Question No 2
________________________________________________________
Sample Input:
88
42
99
Sample Output:
88
Question No 3
Pooja would like to withdraw X $US from an ATM. The cash machine
will only accept the transaction if X is a multiple of 5, and Pooja's
account balance has enough cash to perform the withdrawal
transaction (including bank charges). For each successful withdrawal
the bank charges 0.50 $US. Calculate Pooja's account balance after
an attempted transaction.
Input
Positive integer 0 < X <= 2000 - the amount of cash which Pooja
wishes to withdraw.
Output
The purpose of this problem is to verify whether the method you are
using to read input data is sufficiently fast to handle problems
branded with the enormous Input/Output warning. You are expected
to be able to process at least 2.5MB of input data per second at
runtime.
Input
The input begins with two positive integers n k (n, k<=107). The next
n lines of input contain one positive integer ti, not greater than 109,
each.
Output
Example
Input:
73
51
966369
999996
11
Output:
Question No 5
Xenny and Yana were very keen to celebrate Valentine's Day at their
home. To make preparations for the celebration, they listed
down N tasks that they had to complete.
Please help them find the minimum total time they would take to
complete all N tasks.
Input
The first line of the input contains an integer T denoting the number
of test cases. The description of T test cases follows.
Output
For each testcase, print a single line containing the minimum total
time in seconds Xenny and Yana would take to complete the tasks.
Constraints
Subtask 1: 40 points
• 1 ≤ T ≤ 10
• 1≤N≤3
5
• 1 ≤ Xi, Yi ≤ 10
Subtask 2: 60 points
• 1 ≤ T ≤ 10
• 1 ≤ N ≤ 2*104
• 1 ≤ Xi, Yi ≤ 105
Sample Testcase
Input:
212
321
Output: