Upload
balaji-jadhav
View
7
Download
0
Embed Size (px)
DESCRIPTION
fresher program test
Citation preview
Instructions: Below are three questions. You have to solve all three questions in c#
programming. Do not use any inbuilt functions. You should write your own code.
Problem 1:
Input: The input begins with the number t of test cases in a single line (t<=10). In
each of the next t lines there are two numbers m and n (1 <= m <= n <= 1000000000,
n-m<=100000) separated by a space.
Output: For every test case print all prime numbers p such that m <= p <= n, one
number per line, test cases separated by an empty line.
Example:
Input:
2
1 10
3 5
Output:
2
3
5
7
3
5
Problem 2:
A positive integer is called a palindrome if its representation in the decimal system is
the same when read from left to right and from right to left. For a given positive
integer K of not more than 1000000 digits, write the value of the smallest palindrome
larger than K to output. Numbers are always displayed without leading zeros.
Input: The first line contains integer t, the number of test cases. Integers K are given
in the next t lines.
Output: For each K, output the smallest palindrome larger than K.
Example:
Input:
2
808
2133
Output:
818
2222
Problem 3:
A string is finite sequence of characters over a non-empty finite set Σ.
In this problem, Σ is the set of lowercase letters.
Substring, also called factor, is a consecutive sequence of characters occurrences at least once in a string.
Now your task is simple, for two given strings, find the length of the longest common substring of them.
Here common substring means a substring of two or more strings.
Input: The input contains exactly two lines, each line consists of no more than 250000
lowercase letters, representing a string.
Output: The length of the longest common substring. If such string doesn't exist, print
"0" instead.
Example:
Input:
alsdfkjfjkdsal
fdjskalajfkdsla
Output:
3