Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
100% found this document useful (1 vote)
90 views

C Programs PDF

The document describes a problem to check if a given string is a "dynamic string" based on the frequencies of characters. It provides definitions and constraints for the problem, along with sample input and output. Mr. Bancroft needs help solving this problem as he is busy playing with sandpaper.

Uploaded by

qwerty
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
90 views

C Programs PDF

The document describes a problem to check if a given string is a "dynamic string" based on the frequencies of characters. It provides definitions and constraints for the problem, along with sample input and output. Mr. Bancroft needs help solving this problem as he is busy playing with sandpaper.

Uploaded by

qwerty
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Question No 1

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

Your program is to use the brute-force approach in order to find the


Answer to Life, the Universe, and Everything. More precisely...
rewrite small numbers from input to output. Stop processing input
after reading in the number 42. All numbers at input are integers of
one or two digits.

________________________________________________________

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.

Nonnegative number 0<= Y <= 2000 with two digits of precision -


Pooja's initial account balance.

Output

Output the account balance after the attempted transaction, given


as a number with two digits of precision. If there is not enough
money in the account to complete the transaction, output the
current bank balance.
Question No 4

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

Write a single integer to output, denoting how many integers ti are


divisible by k.

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.

To complete the ith task, Xenny takes Xi seconds and Yana


takes Yi seconds. In order to minimize the disparity in tasks
performed, they decide to do the tasks alternatingly. If Xenny did
the 1st task, then Yana would just wait and watch him until he
completes the task. After that, Yana would start the 2nd task, and
while she does her task, Xenny would just watch her. He would start
the 3rd task only after her completion, and they would keep doing
tasks alternatingly uptil the Nth task. They could also do tasks in the
other order - that is, Yana could do the 1st task, after that Xenny
could do the 2nd task, and so on. Their eventual goal was to minimize
the total time taken by them to complete all Ntasks.

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.

The first line of each testcase contains a positive integer N - the


number of tasks to be completed.
The second line contains N space-separated positive integers
representing the time taken in seconds by Xenny to complete
the ith task.

The third line contains N space-separated positive integers


representing the time taken in seconds by Yana to complete
the ith task.

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:

You might also like