Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
You are given an integer from the Fibonacci sequence. Print index of given
Fibonacci number.
Input
The only line of input contains an integer n.
Output
Print index of given Fibonacci number.
Constraints
2 <= n <= 108
Example#1
Input
2
Output
3
Example#2
Input
13
Output
Input
The first line of input contains integer n, the number of pairs.
Each of next k lines of input contains two space separated integers ai and b
i. (ai; b i) is the ith pair.
Output
Print the number of unique pairs.
Constraints
1 <= n <= 50
1 <= ai , bi <= 100
Example#1
Input
3
1 2
2 3
1 2
Output
2
Explanation: There are two unique pairs: (1; 2), (2; 3).
Example#2
Input
4
1 2
2 3
2 3
1 2
Output
Explanation: There are two unique pairs: (1; 2), (2; 3).
Unique pairs
You are given n integer pairs. Print the number of unique pairs.
Input
The first line of input contains integer n, the number of pairs.
Each of next k lines of input contains two space separated integers ai and b
i. (ai; b i) is the ith pair.
Output
Print the number of unique pairs.
Constraints
1 <= n <= 50
1 <= ai , bi <= 100
Example#1
Input
3
1 2
2 3
1 2
Output
2
Explanation: There are two unique pairs: (1; 2), (2; 3).
Example#2
Input
4
1 2
2 3
2 3
1 2
Output
Explanation: There are two unique pairs: (1; 2), (2; 3).
Joyful Number
A positive number is called joyful if it can be written as the sum of two or more
consecutive positive integers. Your job is to find the n th joyful number.
Input
The only line of input contains an integer n.
Output
Print the nth joyful number.
Constraints
0 <= n <= 106
Example#1
Input
2
Output
6
Explanation: 0) 3 = 1 + 2
1) 5 = 2 + 3
2) 6 = 1 + 2 + 3
Example#2
Input
3
Output
Explanation: 0) 3 = 1 + 2
1) 5 = 2 + 3
2) 6 = 1 + 2 + 3
3) 7 = 3 + 4
Input
The first line of input contains an integer n, the length of the given string.
The second line of input contains a string.
Output
Print "YES" (without quotes) if n is divisible by 3, print "NO" (without quotes)
otherwise.
Constraints
1 <= n <= 100
Example#1
Input
4
3333
Output
YES
Example#2
Input
4
1234
Output
NO
Output
Print the number of substrings that start and end with '0'.
Constraints
1 <= n <= 100
Example#1
Input
4
0101
Output
3
Explanation: There are three substrings that start and end with '0': "0", "010".
Example#2
Input
4
1011
Output
Explanation: There is one substring that starts and ends with '0': "0".
Prime numbers
You are given a positive integer n. You must find the largest possible prime
number p, which satisfies the following:
p = 2k - 1
p<n
Input
The only line of input contains an integer n.
Output
Print p. If there is no such p, print -1.
Constraints
1 <= n <= 108
Example#1
Input
10
Output
7
Example#2
Input
40
Output
31
Input
The only line of input contains four space separated integers: n, k, a and b.
Output
Print the greatest common divisor (GCD) of n and k which is in range [a; b].
Constraints
1 <= n <= 10000
1 <= k <= 10000
1 <= a <= 10000
1 <= b <= 10000
Example#1
Input
12 4 1 3
Output
2
Example#2
Input
14 28 1 2
Output
Input
The only line of input contains two space separated integers n and k.
Output
Print 1 if nk > kn, print -1 otherwise.
Constraints
1 <= n <= 105
1 <= k <= 105
Example#1
Input
3 4
Output
1
Example#2
Input
1 2
Output
-1
Explanation: 12 = 1, 21 = 2, 1 < 2.
Factorial digits
You are given a positive integer n. You must find the number of digits in
factorial of n.
Input
The only line of input contains an integer n.
Output
Print the number of digits in factorial of n.
Constraints
1 <= n <= 105
Example#1
Input
5
Output
3
Example#2
Input
4
Output
Input
The only line of input contains an integer n.
Output
Print "YES" (without quotes) if the given number is pernicious number, print "NO"
(without quotes) otherwise.
Constraints
1 <= n <= 28
Example#1
Input
3
Output
YES
Example#2
Input
4
Output
NO
Explanation: 4 is not pernicious number. Binary representation of 4:
00000000000000000000000000000100. As you can see digit sum is 1, 1 is not
prime number.
Geometric Progression
You are given first term (a) and common ratio (r) of Geometric Progression.
Find nth term of the given Geometric Progression.
Input
The only line of input contains three space separated integers a, r and n.
Output
Print nth term of the given Geometric Progression.
Constraints
1 <= a, r, n <= 1000
It is guaranteed that result will not be greater than 108.
Example#1
Input
2 3 4
Output
54
Explanation:
The first term: 2
The second term: 2 * 3 = 6
The third term: 2 * 3 * 3 = 18
The fourth term: 2 * 3 * 3 * 3 = 54
Example#2
Input
5 5 2
Output
25
Explanation:
The first term: 5
The second term: 5 * 5 = 25
Factorial zeroes
You are given an integer n. Print the number of trailing zeroes in factorial of
n.
Input
The only line of input contains an integer n.
Output
Print the number of trailing zeroes in factorial of n.
Constraints
1 <= n <= 108
Example#1
Input
5
Output
1
Example#2
Input
10
Output
LCM
You are given an array consisting of n integers. Print LCM (Least Common
Multiple) of the given array.
Input
The first line of input contains an integer n, the number of elements in the
given array.
The second line of input contains n space separated integers, elements of
the given array.
Output
Print LCM (Largest Common Multiple) of the given array.
Constraints
1 <= n <= 10
1 <= arr[i] <= 100. arr[i] is the ith element of the given array.
Example#1
Input
3
1 2 3
Output
6
Example#2
Input
3
2 4 8
Output
Prime Number
For a given number N check if it is prime or not. A prime number is a number which
is only divisible by 1 and itself.
Input
First line contains an positive integer N.
Output
For each testcase, in a new line, print "Yes" if it is a prime number else print "No".
Constraints
1 <= N <= 100
Example#1
Input
5
Output
Yes
Input
The firs line of input contains 4 integers: n, l, r and p, where n is the number
of elements in the given array, l and r - range, p - prime number.
The second line of input contains n space separated integers, elements of
the given array.
Output
Print the product in range [l, r] under modulo p, where p is a prime number.
Constraints
1 <= n <= 106
1 <= l <= r < n
1 <= p <= 108
Example#1
Input
4 1 2 5
2 5 6 9
Output
0
Example#2
Input
4 1 3 13
2 5 6 9
Output
10
Digits GCD
You are given an integer n. Print GCD (Greatest Common Divisor) of its
digits.
Input
The only line of input contains an integer n.
Output
Print GCD (Greatest Common Divisor) of digits of n.
Constraints
1 <= n <= 108
Example#1
Input
34
Output
1
Explanation: GCD(3, 4) = 1
Example#2
Input
68
Output
Explanation: GCD(6, 8) = 2
A ladder
John is standing at the bottom of the ladder and wants to reach the top. There
are n stairs and in one move he can climb either one stair or two stairs at a
time. Print the number of ways, John can reach the top.
Input
The only line of input contains an integer n, the number of stairs.
Output
Print the number of ways, John can reach the top.
Constraints
1 <= n <= 30
Example#1
Input
3
Output
3
Explanation: If there are 3 stairs, there are 3 ways of reaching the top:
1) 0 -> 1 -> 2 -> 3
2) 0 -> 1 -> 3
3) 0 -> 2 -> 3
Example#2
Input
2
Output
Explanation: If there are 2 stairs, there are 2 ways of reaching the top:
1) 0 -> 1 -> 2
2) 0 -> 2
Last digits
You are given three positive integers n, a and b. Print last n digits of a b.
Input
The only line of input contains three space separated integers n, a and b.
Output
Print last n digits of ab.
Constraints
1 <= a, b < 20
1 <= n <= length(ab)
Example#1
Input
1 3 3
Output
7
Example#2
Input
2 4 2
Output
16
Sexy prime
In mathematics, sexy primes are prime numbers that differ from each other
by six.
You are given a range of the form [l, r]. Print the number of all the sexy prime
pairs in the given range.
Input
The only line of input contains two space separated integers l and r.
Output
Print the number of all the sexy prime pairs in the given range.
Constraints
1 <= l <= r <= 1000
Example#1
Input
5 12
Output
1
Explanation: There is only one sexy prime pair in range [5; 12] (5; 11). 5 is
prime, 11 is prime, 5 + 6 = 11.
Example#2
Input
14 22
Output
Input
The only line of input contains three space separated integers a1, d and k.
Output
Print "YES" (without quotes) if k is part of given Arithmetic Progression, print
"NO" (without quotes) otherwise.
Constraints
1 <= a1 <= 1000
1 <= d <= 100
Example#1
Input
1 2 5
Output
YES
Example#2
Input
1 2 6
Output
NO
Explanation: In this case the first element is 1 and d is 2. Thus 6 is not a part
of the given Arithmetic Progression
Input
The first line contains two space separated integers N and M
Each of the next N lines contains M space separated integers
Output
Single integer as sum of path members
Constraints
(1 <= N,M <= 100)
Example#1
Input
4 4
1 1 100 1
1 100 1 1
1 1 100 1
1 1 1 100
Output
400
Example#2
Input
4 4
1 1 1 100
100 1 1 1
1 1 1 100
100 1 1 1
Output
202
Spiral Matrix
Given a 2D array, print it in spiral form starting from very first element.
For example if array is :
1 2 3
456 Spiraled form will be 1 -> 2 -> 3 -> 6 -> 9 -> 8 -> 7 -> 4 -> 5
7 8 9
Input
The first line contains two space separated integers N and M
Each of the next N lines contains M space separated integers
Output
Spiraled 2D array
Constraints
(1 <= N,M <= 100)
Example#1
Input
4 4
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
Output
1 2 3 4 4 4 4 3 2 1 1 1 2 3 3 2
Example#2
Input
1 3
1 2 3
Output
1 2 3
Explanation: While we have 1 x 3 matrix, spiral will be first and only row
Input
The first line contains two space separated integers N and M
Each of the next N lines contains M space separated integers
Output
Index of row with maximum number of 1s.
Constraints
(1 <= N,M <= 100)
Example#1
Input
3 4
0 0 1 1
0 0 0 1
0 0 0 1
Output
0
Example#2
Input
2 2
0 1
1 1
Output
Totient Function
Totient function for an input K is count of numbers in range (1, K) that are
relatively prime to K i.e the numbers whose GCD which K is 1, you can read
more about the function on wikipedia
Input
The first and only line contains single integer K
Output
Totient number t(K)
Constraints
( 1 <= K <= 1010)
Example#1
Input
6
Output
2
Explanation:
The formula basically says that the value of t(K) is equal to K multiplied by
product of (1 – 1/p) for all prime factors p of K. For example value of t(6) = 6
* (1-1/2) * (1 – 1/3) = 2.
Example#2
Input
10
Output
Output
Number of ways we can merge the given arrays
Constraints
( 1 <= N, M <= 104)
Example#1
Input
2
2
Output
6
Explanation:
Consider that first array is {1, 2} and second is {3, 4}, possible merges will
be:
1. {1, 2, 3, 4}
2. {1, 3, 2, 4}
3. {3, 4, 1, 2}
4. {3, 1, 4, 2}
5. {1, 3, 4, 2}
6. {3, 1, 2, 4}
Example#2
Input
1
2
Output
Explanation:
Consider that first array is {1} and second is {2,3}, possible merges will be:
1. {1, 2, 3}
2. {2, 3, 1}
3. {2, 1, 3}
Product Triplets
For a given array, find how many triples of indices (i < j < k), such that arr[i]
* arr[j] * arr[k] is minimum
Input
The first line contains single integer N
The second line contains N space separated integers
Output
Number of minimum triplet products
Constraints
(3 <= N <= 106)
Example#1
Input
6
3 3 1 2 7 9
Output
2
Example#2
Input
4
2 2 2 2
Output
Stick Cutting
For a given stick of size N, find the number of ways it can be cut into K pieces
Input
The first line contains single integer N
The second line contains single integer K
Output
Number of ways stick can be cut into K pieces.
Constraints
(1 <= N <= 105)
Example#1
Input
4
2
Output
3
Example#2
Input
3
2
Output
Input
The first line contains single integer A
The second line contains single integer X
The third line contains single integer N
Output
N space separated integer as series of binomial expression
Constraints
(1 <= A,X <= 104)
(1 <= N <= 10)
Example#1
Input
2 2 4
Output
16 64 96 64 16
Example#2
Input
1
1
5
Output
1 5 10 10 5 1
Explanation:
Narayana
For a given integers N and K, find Narayana number which is given by :
In combinatorics, the Narayana numbers N(n, k), n = 1, 2, 3 ..., 1 ≤ k ≤ n,
form a triangular array of natural numbers, called Narayana triangle, that
occur in various counting problems. N(n, k) formula is based on the
expression:
Input
The first line contains single integer N
The second line contains single integer K
Output
Narayana number - N(n, k)
Constraints
Value of N(N, K)
Example#1
Input
5
3
Output
20
Example#2
Input
6
6
Output
1
Straight roads
You are working for a company which constructs roads. At the moment you are
given a task: There are n cities. You must determine whether it is possible to
construct two roads (not necessarily distinct) and satisfy the following:
Assume that each point is distinct and coordinates of each them are integers.
Input
The first line of input contains integer n.
Next n lines contains two integers xi and yi – coordinates of i point.
th
Output
Print “YES” (Without quotes) if it is possible construct roads, “NO” (Without
quotes) otherwise.
Constraints
0 < n <= 100000.
-100000000 <=xi <= 100000000
-100000000 <=yi <= 100000000
Example #1
Input
5
2 9
-1 -4
-3 -8
-4 -8
7 2
Output
NO
Example #2
Input
4
1 1
2 2
3 4
2 1
Output
YES
We can draw 2 straight lines such that every point lies on them.
Input
Input description...
Output
Output description...
Constraints
Constraints details...
Example#1
Input
Input data...
Output
Output data...
Explanation:
Example#2
Input
Input data...
Output
Output data...
Explanation:
Input
Input description...
Output
Output description...
Constraints
Constraints details...
Example#1
Input
Input data...
Output
Output data...
Explanation:
Example#2
Input
Input data...
Output
Output data...
Explanation:
Count Derangements
You are given N balls numbered from 1 to N and there are N baskets
numbered from 1 to N in front of you, the ‘i’th basket is meant for the ‘i’th ball.
The task is to calculate the number of ways in which none of the balls goes
into their respective basket.
Input
Each test case consist of a single line containing an integer N.
Output
Corresponding to each test case, print the desired output in a new line. Since
the answer can be large, print it modulo 109 + 7.
Constraints
1 ≤ N ≤ 105
Example#1
Input
2
Output
1
Example#2
Input
3
Output
Explanation: There are two ways in which no ball goes into respective
basket.
1. Ball 1 will go in basket 2 , ball 2 will go in basket 3 and ball 3 will go into
basket 1.
2. Ball 1 will go in basket 3 , ball 2 will go in basket 1 and ball 3 will go into
basket 2. So answer is 2.
Lucky sequence
John has the integer n and wants to generate lucky arrays with the length n. He thinks
that an array is lucky if it contains only integers from 1 to n and meets one of the
two conditions:
1) Each element, starting from the second one, is no more than the preceding one.
2) Each element, starting from the second one, is no less than the preceding one.
John started generating lucky arrays with the size n. How many different arrays can
be generated.
Input
The only line of input contains an integer n which is the size of the array.
Output
Print the answer modulo 1000000007.
Constraints
1 ≤n≤ 100000
Example#1
Input
1
Output
1
Example#2
Input
2
Output
Perfect subset
We call a subset Perfect, if the product of all of its elements is the square of
some positive integer. For example, {2, 2} is a perfect subset, because 2 x 2
= 4. You are given an array of n integers. Your task is to find the number of
different ways to select a perfect subset.
Input
The first line of input contains integer n, number of elements in the array.
The second line contains n space separated integers (k1, k2, ..., kn).
Output
Print one integer — the number of different ways to choose some elements
so that their product is a square of a certain integer modulo 109 + 7.
Constraints
1 <= n <= 100000.
1 <= ki <= 50
Example #1
Input:
1
64
Output:
1
Example #2
Input:
2
70 70
Output:
1
Just one way. 70 x 70
Input
The first line contains two integers n and k.
Output
Print the number of The Silver Permutations for given n and k.
Constraints
4 ≤n≤ 1000.
1 ≤k≤ 4.
Example #1
Input:
4 2
Output:
7
Example #2
Input:
400 1
Output:
Damaged indicators
John is a famous inventor. Robot JR004 is one of his inventions. JR004 has
a sequence of n indicators for communication. Unfortunately some indicators
of JR004 are damaged at the moment and need to be repaired. JR004 can
self-repair. At each step it can repair a damaged indicator if there is at least
one adjacent indicator which is not damaged.
John wants to determine how many different ways are there, to repair all
damaged indicators. He is not good at programming and needs your help.
Write a program which takes two integers – n and m, and an array of integers
- arr. n is the number of indicators. m is the number of indicators which
are not damaged. arr is the array of integers containing indexes of indicators
which are not damaged. Your program must return the number of different
possible ways to repair all the indicators modulo 1000000007.
Input
The first line of input contains two integers n and m. n - number of indicators.
m – number of indicators which are not damaged.
The second line of input contains m space separated integers k 1, k2, …, kn –
indexes of indicators which are not damaged.
Output
Print the number of different possible ways to repair all the indicators modulo
1000000007.
Constraints
0 < n < 1000.
0 < m <= n.
0 < ki <= n
Example #1
Input
4 4
1 2 3 4
Output
1
Example #2
Input
5 3
1 2 5
Output
2
Way 1: 3 4
Way 2: 4 3
Input
The only line of input contains an integer n.
Output
Print the value returned by Euler’s Totient function for n.
Constraints
1 <= n <= 100000
Example#1
Input
3
Output
2
Explanation: There are two positive integers (1 <= k <= 3) that are relatively prime
to 3: GCD(1, 3) = 1, GCD(2, 3) = 1.
Example#2
Input
8
Output
Explanation: There are four positive integers (1 <= k <= 8) that are relatively prime
to 3: GCD(1, 8) = 1, GCD(3, 8) = 1, GCD(5, 8) = 1, GCD(7, 8) = 1,
Output
Print the integer k (the best friend of n)
Constraints
1 <= n <= 1000000
Example #1
Input:
1
Output:
0
We do not need to make any operations, because (1, 1) is an initial pair and
n is 1
Example #2
Input:
2
Output:
1
Degree of Fibonacci
John loves mathematics very much. Recently he learnt about the Degree of
Fibonacci. If we are given a sequence of integers, we call the Degree of
Fibonacci a longest prefix of the sequence, whose members satisfy the
following: ai = ai - 1 + ai - 2, where i >= 3 (We start counting from 1).
At the moment John has an array consisting of n integers. He wants to
rearrange the elements of the array in such way that the Degree of Fibonacci
is maximal. He wants to write a program which takes integer n and array of
n integers as arguments and calculates the maximum possible Degree of
Fibonacci for the sequence which is generated by the elements of the given
array. He is not good at programming and needs your help!
Input
The first line of input contains integer n.
The second line of input contains n space separated integers.
Output
Print the maximum possible Degree of Fibonacci for the sequence generated
by the given numbers.
Constraints
2 <= n <= 1000
-1000000 <= arr[i] <= 1000000. arr[i] is the element of the array.
Example #1
Input
4
1 2 3 1
Output
4
Example #2
Input
4
1 -10 1 2
Output
3
Greedy calculator
John is a famous inventor. Recently he invented a calculator. This calculator
is capable of just adding two numbers and is "greedy": If we try to sum up
two numbers with this calculator, it will choose one of such base k positional
notation, that the number of symbols in a result will be maximal. For example:
If the numbers are 9 and 7, it will choose base 10 positional notation and the
length of the result will be 2 (910 + 710 = 1610). Or if the numbers are 11 and
11, it will choose base 2 positional notation and the length of a result will be
3 (112 + 112 = 1102). Maximal number of symbols in a result for these
examples are 2 and 3.
Sarah wants to use John's calculator, but before she wants to know the
length of a result. Help Sarah, write a program, which takes two integers m
and n as arguments, and prints the length of the result returned by the greedy
calculator.
Input
The only line of input contains two space separated integers, n and m.
Output
Print the length of the result returned by greedy calculator.
Constraints
The only line of input contains two space separated integers - n and m.
Example #1
Input
84 89
Output
3
Output
2
13 + 23 = 103.
Maybe, It is not necessary to chose exactly base 3 numeral system and
maybe there are other numeral systems where the number of symbols in a
result is 3, but the maximal number of symbols in a result can not be more
than 2.
Squareland
Squareland is a country which has a shape of a n x n square. Each (i, j) cell
of the Squareland may be a city or a village.
Write a program which takes a description of the Squareland and determines
if it is possible to walk from any city to another city using a path of side-
adjacent cities changing the direction at most once during the path.
Input
The first line of input contains integer n. n x n is the size of the Squareland.
Each of next n lines contains n space separated characters 'C' or 'V'.
Character 'C' denotes a city and character 'V' denotes village.
Output
Print "YES" (without quotes) if it is possible to walk from any city to another
city using a path of side-adjacent cities changing the direction at most once
during the path, "NO" (without quotes) otherwise.
Constraints
1 <= n <= 50.
It is guaranteed, that there is at least one city in the Squareland.
Example#1
Input
4
C C C C
C C C C
V C V V
V V V V
Output
YES
Explanation: We are able to walk from any city to another city using a path
of side-adjacent cities changing the direction at most once during the path.
Example#2
Input
4
C C C C
C V C C
V V V C
V V V V
Output
NO
Explanation: It is not possible to walk from any city to another city using a
path of side-adjacent cities changing the direction at most once during the
path. For example, we need to change the direction from (1, 2) to (3, 2) twice.
We must change the direction at (1, 1) and at (3, 1).
C(1,1) C(2,1) C(3,1) C(4,1)
C(1,2) V(2,2) C(3,2) C(4,2)
V(1,3) V(2,3) V(3,3) C(4,3)
V(1,4) V(2,4) V(3,4) V(4,4)
Input
The first line of each test case contains a positive integer N which denotes
the size of the array. In the next line are N space separated positive integers
which are the value of array A.
Output
Print two space separated integers which denote the number of multisets
with mean as Max and the number of multisets with mean as Min. The output
should be done modulo 109+7.
Constraints
1 ≤ N ≤ 1000
1≤A[i] ≤1000
Example#1
Input
5
3 1 2 3 4
Output
1 1
Input
The only line of input contains two space separated integers, n and k.
Output
Print the number of digits in the product of n and k.
Constraints
1 <= n, k <= 108
Example#1
Input
4 5
Output
20
Example#2
Input
10 10
Output
Explanation: 10 * 10 = 100. There are three digits in 100 ('1', '0' and '0').
Non square
You are given a positive integer n. Print the nth number which is not a perfect
square among natural numbers (1, 2, 3, … ).
Input
The only line of input contains an integer n.
Output
Print the nth number which is not a perfect square among natural numbers (1,
2, 3, … ).
Constraints
1 <= n <= 108
Example#1
Input
4
Output
6
Output
11
isPower
You are given a positive integer n. Print "YES" (without quotes) if n can be
expressed as ab where b > 1 and a > 0. a and b both are positive integers. Otherwise
print "NO" (without quotes).
Input
The only line of input contains an integer n.
Output
Print "YES" (without quotes) if n can be expressed as ab where b > 1 and a > 0. a and
b both are integers. Otherwise print "NO" (without quotes).
Constraints
1 <= n<= 108
Example#1
Input
27
Output
YES
Explanation: 27 = 33
Example#2
Input
10
Output
NO
Input
The only line of input contains an integer n.
Output
Print the minimum value of k.
Constraints
1 <= n <= 108
Example#1
Input
6
Output
3
Example#2
Input
8
Output
4
n as sum of 1, 3, 4
You are given an integer n. Print the number of ways to express n as sum of
1, 3 and 4.
Input
The only line of input contains a single integer.
Output
Print the number of ways to express n as sum of 1, 3 and 4.
Constraints
4 <= n <= 35
Example#1
Input
5
Output
6
Example#2
Input
4
Output
Paint stairs
You are given n stairs and 2 colors red, and blue. You should paint given
stairs by given colors (each step by each color).
There is only one constraint: We cannot paint two steps directly after each
other with a red color.
Print the number of ways we can paint n stairs.
Input
The only line of input contains integer n.
Output
Print the number of ways we can paint n stairs.
Constraints
1 <= n <= 35
Example#1
Input
3
Output
5
Example#2
Input
2
Output
3
Input
The only line of input contains an integer n.
Output
Print total number of ways to express n as sum of odd positive integers.
Constraints
1 <= n <= 35
Example#1
Input
3
Output
2
Example#2
Input
4
Output