Plus
Pin


Problem description Progress
ID 33566. Sequence length
Темы: while loop   

The program receives as input a sequence of non-negative integers, each number is written on a separate line. The sequence ends with the number 0, upon reading which the program should finish its work and print the number of members of the sequence (not counting the terminating number 0). Numbers following the number 0 do not need to be read.

Input data: You enter a sequence of integers ending with the number 0 (the number 0 itself is not included in the sequence).
Output: Print the answer to the problem.

Examples
# Input Output
1 1
3
4
8
0
2
1
4

ID 33706. Jogging
Темы: while loop   

On the first day, the athlete ran x kilometers, and then every day he increased the distance by 10% from the previous value. Given the number y determine the number of the day on which the athlete's run will be at least y kilometers.
 

Input 
The program receives as input real numbers x and y (one number per line).

Imprint 
The program should output one natural number.
 

 

Examples
# Input Output
1 10
20
9

ID 33707. Bank interest
Темы: while loop   

The deposit in the bank is x rubles. Every year it increases by  p percent, after which the fractional part of kopecks is discarded. Determine in how many years the contribution will be at least y rubles.

Input
The program receives three natural numbers as input: xpy (one number per line).

Imprint 
The program should output one integer.
 

 

Examples
# Input Output
1 100
10
200
8

ID 33711. splitter
Темы: while loop   

Performer “The Splitter” convert natural numbers. It has two commands: “Subtract 1” and “Divide by 2”, the first command reduces the number by 1, the second command reduces the number by half if it is even, otherwise an error occurs.

Given two natural numbers A and B (\(A>B\)). Write an algorithm for the Splitter that converts the number A to the number B and at the same time contains the minimum number of instructions. Algorithm commands should be output one per line, the first command is denoted as -1, the second command as :2.

Input
Two natural numbers A and B are entered (one number per line).

Imprint
Print the answer to the problem.
 

 

Examples
# Input Output
1 100
1
:2
:2
-1
:2
:2
:2
-1
:2

ID 33715. Artist Aquarius
Темы: while loop   

The performer “Aquarius” there are two vessels, the first with a volume of A liters, the second with a volume of B liters, as well as a tap with water. Aquarius can perform the following operations:

  1. Fill vessel A (indicated by >A).
  2. Fill vessel B (indicated by >B).
  3. Pour water out of vessel A (denoted by A>).
  4. Pour water out of vessel B (denoted by B>).
  5. Pour water from vessel A into vessel B (indicated as A>B).
  6. Pour water from vessel B into vessel A (indicated as B>A).

The command to pour from one vessel to another results in either the first vessel being completely emptied or the second vessel being completely filled.

Input: The program receives as input three natural numbers A, B, N, not exceeding 104.
Output: It is necessary to display the Aquarius action algorithm, which allows you to get exactly N liters in one of the vessels, but if such an algorithm does not exist, then the program should display the text Impossible.

The number of operations in the algorithm should not exceed 105. It is guaranteed that if the problem has a solution, then there is a solution that contains no more than 105 operations.


Examples
# Input Output
1 3
5
1
>A
A>B
>A
A>B
2 3
5
6
Impossible

ID 33703. binary logarithm
Темы: while loop   

Given a natural number N print the smallest integer k such that \(2^k >= N.\) Raising to a power cannot be used!

Input 
Enter a natural number N.

Imprint 
Print the answer to the problem.
 

 

Examples
# Input Output
1 7 3

ID 33710. Fibonacci numbers
Темы: while loop   

The Fibonacci sequence is defined like this:

\(\varphi_0=0, \varphi_1=1, ..., \varphi_{n}=\varphi_{n-1 }+\varphi_{n-2}\).

Given a number \(n\ge 1\) define \(n\)th Fibonacci number \(\varphi_n\).

Input
A natural number n is entered.

Imprint
Print the answer to the problem.
 

 

Examples
# Input Output
1 6 8

ID 33702. Number squares
Темы: while loop   

Given a natural number N, print in ascending order all squares of natural numbers not exceeding N.

Input 
One natural number is entered.

Imprint 
Print all numbers in one line, separated by spaces.
 

 

Examples
# Input Output
1 50 1 4 9 16 25 36 49

ID 33704. Elements larger than previous
Темы: while loop   

The sequence consists of natural numbers and ends with the number 0. Determine how many elements of this sequence are greater than the previous element.

Input 
A sequence of natural numbers is entered (one number per line), ending with the number 0 (the number 0 itself is not included in the sequence, but serves as a sign of its end).

Imprint 
Print the answer to the problem.

Examples
# Input Output
1 2
3
5
0
2

ID 33705. How many elements equal to the maximum
Темы: while loop   

The sequence consists of natural numbers and ends with the number 0. Determine how many elements of this sequence are equal to its largest element.

Input 
A sequence of natural numbers is entered, ending with the number 0 (the number 0 itself is not included in the sequence, but serves as a sign of its termination).

Imprint 
Print the answer to the problem.
 

 

Examples
# Input Output
1 9
7
0
1
2 1
3
3
1
0
2

ID 33708. Second highest in sequence
Темы: while loop   

The sequence consists of different natural numbers and ends with the number 0. Determine the value of the second largest element in this sequence.

Input 
A sequence of natural numbers is entered, ending with the number 0 (the number 0 itself is not included in the sequence, but serves as a sign of its termination).

Imprint 
Output the answer to the problem
 

 

Examples
# Input Output
1 9
7
0
7

ID 33709. The sum of the elements of the sequence - 2
Темы: while loop   

Find the sum of a sequence of natural numbers if the sign of the end of the sequence is two consecutive numbers 0. Numbers after two zeros should not be involved in solving the problem.

Input 
A sequence of natural numbers is entered.

Imprint
Print the answer to the problem.
 

 

Examples
# Input Output
1 2
0
7
0
9
0
0
3
18

ID 33712. The maximum number of equals in a row
Темы: while loop   

You are given a sequence of natural numbers ending with the number 0. Determine the largest number of consecutive elements of this sequence that are equal to each other.

Input
 A sequence of natural numbers is entered, ending with the number 0 (the number 0 itself is not included in the sequence, but serves as a sign of its end).

Imprint 
Print the answer to the problem.
 

 

Examples
# Input Output
1 1
7
7
9
1
0
2

ID 33714. Standard deviation
Темы: while loop   

Given a sequence of natural numbers \(x_1, x_2, ..., x_n\)Standard deviation is called value

\(\sigma = \sqrt{\frac{(x_1-s)^2+(x_2-s)^2+\ ldots+(x_n-s)^2}{n-1}}\),

where \(s=\frac{x_1+x_2+\ldots+x_n}{n}\) — arithmetic mean of a sequence.

Determine the standard deviation for the given sequence of natural numbers ending in 0.

Input 
A sequence of natural numbers is entered, ending with the number 0 (the number 0 itself is not included in the sequence, but serves as a sign of its termination).

Imprint 
Print the answer to the problem.
 

 

Examples
# Input Output
1 1
7
9
0
4.16333199893

ID 33713. Maximum length of a monotone fragment
Темы: while loop   

Given a sequence of natural numbers ending with the number 0. Determine the maximum length of a monotone fragment of the sequence (that is, such a fragment where all elements are either greater than the previous one or less).

Input
A sequence of natural numbers is entered, ending with the number 0 (the number 0 itself is not included in the sequence, but serves as a sign of its termination).

Imprint 
Print the answer to the problem.
 

 

Examples
# Input Output
1 9
7
7
9
7
0
2

ID 34798. Data stream processing - 1
Темы: while loop   

Given a non-empty sequence of integers ending in zero. Zero is not included in the sequence, it serves as a sign of its end. Find the sum of all numbers in the sequence greater than x. If there are no such numbers in the sequence, then print 0.

Input 
The first line specifies the number x, then (from the second line) the numbers of the sequence are specified. Zero - a sign of the end of input.

Imprint
Print the answer to the problem.
 

 

Examples
# Input Output
1 3
5
3
4
7
0
16

ID 24682. Analysis of the digits of a number - 5
Темы: while loop   

Given a natural number N (N<=109). Find the sum of its maximum and minimum digits

Input and output example

test number Input Output
1 45545 9
2 111 2

ID 24679. Analysis of the digits of the number - 7
Темы: while loop   

Given a natural number N (N<=109) and a number k. Determine the product of the digits of the number N, which are greater than k. If there are no such digits, then print 0.

Input and output example

test number Input Output
1 45545
4
125
2 1235
2
15

ID 2959. Analysis of the digits of the number - 10
Темы: while loop   

Given a natural number n, determine its first digit from the left.

Input
The program receives as input a natural number (n <= 109).

Imprint
Print the answer to the problem.
 
 

Examples
# Input Output
1 45545 4

ID 2958. Analysis of the digits of the number - 11
Темы: while loop   

The first line contains the natural number n 
Display
-  product of odd digits of a number
(it is assumed that there is at least one odd digit in the number)

Sample input and output

test number Input Output
1 45545 125

ID 2957. Analysis of the digits of the number - 12
Темы: while loop   

The first line contains the natural number n 
Display
- sum of even digits of number n

Sample input and output

test number Input Output
1 65562 14

ID 24685. Analysis of the digits of a number - 2
Темы: while loop   

Given a natural number N (N<=109). Determine the ordinal number of its minimum digit, counting from the beginning of the number (if there are several such digits, then print the number of the first of them)

Input and output example

test number Input Output
1 45545 1
2 100 2

ID 24684. Analysis of the digits of a number - 3
Темы: while loop   

Given a natural number N (N<=109). Determine the ordinal number of its maximum digit, counting from the beginning of the number (if there are several such digits, then print the number of the first of them)

Input and output example

test number Input Output
1 45545 2
2 100 1

ID 24683. Analysis of the digits of a number - 4
Темы: while loop   

Given a natural number N (N<=109). Determine the ordinal number of its maximum digit, counting from the end of the number (if there are several such digits, then print the number of the first of them)

Input and output example

test number Input Output
1 45545 1
2 100 3

ID 24681. Analysis of the digits of a number - 6
Темы: while loop   

Given a natural number N (N<=109). Determine how much its maximum digit exceeds the minimum

Input and output example

test number Input Output
1 45545 1
2 111 0

ID 24678. Analysis of the digits of the number - 8
Темы: while loop   

Given a natural number N (N<=109). Determine how many times the last digit occurs in it (excluding the last digit).

Input and output example

test number Input Output
1 45545 2
2 445 0

ID 2956. Analysis of the digits of the number - 17
Темы: while loop   

The first line contains the number n >= 0
The second line contains the number  B and the number k
Display
- the word YES, if the digit B occurs in the number more than k times
- the word NO, if the digit B occurs in the number less than k times
- number k, if digit B occurs exactly k times

Sample input and output

test number Input Output
1 45545
5 6
NO
 
2 45545
5 3
3

ID 34796. We process the digits of the number - 2
Темы: while loop   

Given a natural number N. Determine the sum of its digits greater than z. If there are no such digits in the number, print 0.

Input 
Enter two numbers separated by a space, first a natural number N, then - z (\(0<=z<=9\) ).

Imprint
Print the answer to the problem.
 

 

Examples
# Input Output
1 432 2 7

ID 34800. Data flow processing - 3
Темы: while loop   

Given a non-empty sequence of integers ending in zero. Zero is not included in the sequence, it serves as a sign of its end. Find the product of the last digits of all numbers in the sequence greater than 13. If there are no such numbers, print 0.

Input 
The numbers of the sequence are given as input (all numbers are not more than 100 modulo). Zero - a sign of the end of input. 

Imprint 
Print the answer to the problem (it is guaranteed that the answer is always less than 264).
 

 

Examples
# Input Output
1 13
15
3
4
17
0
35

ID 2955. Analysis of the digits of the number - 18
Темы: while loop   

The first line contains the natural number n 
The second line contains the number  B
Display the word YES if the digit B does not occur in the number 
the word NO if the digit B occurs in the number 

Sample input and output

test number Input Output
1 45545
6
YES

ID 2953. Analysis of the digits of the number - 19
Темы: while loop   

The first line contains the natural number n 
The second line contains the numbers A and B
Display the letter A (English) if the number A occurs more often than the number B
the letter B, if the number B (English) occurs in the number more often than the number A
= sign if digit A and digit B occur the same number of times

Sample input and output

test number Input Output
1 45545
4 5
In
2 12221
2 1
A

ID 2954. Analysis of the digits of the number - 13
Темы: while loop   

The first line contains the natural number n 
Display the maximum digit of n

Sample input and output

test number Input Output
1 102983 9

ID 34797. We process the digits of the number - 3
Темы: while loop   

Given a natural number N that does not contain the digit 0. Determine the product of its digits that are multiples of z. If there are no digits that are multiples of z, then print 0.

Input 
Enter two numbers separated by a space, first a natural number N, then - z (\(0 < z <= 9\ )).

Imprint 
Output the answer to the problem.

 

Examples
# Input Output
1 432 2 8

ID 24687. Analysis of the digits of the number - 14
Темы: while loop   

The first line contains the natural number n 
The second line contains the number B
Display
-  the word YES, if the sum of its digits is greater than the number B, and the number itself is even
-  otherwise print the word NO

Sample input and output

test number Input Output
1 45545 
15
NO
 
2 554
5
YES
 

ID 2961. Analysis of the digits of the number - 15
Темы: while loop   

The first line contains the natural number n 
The second line contains the number B
Display
-  word YES, if the number itself and the sum of its digits are multiples of B
-  otherwise print the word NO

Sample input and output

test number Input Output
1 45545 
5
NO
 
2 555
5
YES

ID 2960. Analysis of the digits of the number - 16
Темы: while loop   

The first line contains the number n >=0 
Display on screen:

  • sign > if the first digit is greater than the last;
  • sign < if the first digit is less than the last;
  • sign = if the first and last digits are equal.

Sample input and output
test number Input Output
1 45545 <
 
2 44 =

ID 34917. The greatest length of a monotone fragment
Темы: while loop   

Given a sequence of natural numbers ending with the number 0 (0 is not included in the sequence). Determine the maximum length of a monotonous fragment of the sequence (that is, such a fragment where all elements are either greater than the previous one or less).

Numbers after 0 do not need to be read.

Input: Given a sequence of natural numbers ending in 0.

Output: Print the answer to the problem.

Examples
# Input Output
1 1
7
7
8
1
0
2

ID 34918. Number of local maxima
Темы: while loop   

An element of a sequence is called a local maximum if it is strictly greater than the previous and subsequent elements of the sequence. The first and last element of the sequence are not local maxima.

Given a sequence of natural numbers, the sign of the end of which is the number 0 (0 is not included in the sequence). Determine the number of strict local maxima in this sequence. 

Numbers after 0 do not need to be read.

Input: Given a sequence of natural numbers, the sign of the end of which is the number 0.
Output: Output the answer to the problem.

Examples
# Input Output
1 1
2
1
2
1
0
2

ID 34807. * The two largest digits are 2
Темы: while loop   

Given a natural number N (\(N<=10^9\)). Determine the two largest digits of a number. 

Input 
The input is a natural number.

Imprint 
Output two space-separated digits, first the largest digit of the number, then the second largest (not equal to the first largest digit). If the number consists of the same digits, print NO.
 

 

Examples
# Input Output
1 45545 5 4
2 111 NO

ID 2964. Nested Loops - 1
Темы: for loop    while loop    Cycles   

Two numbers N and K are entered. Print the number of numbers from 1 to N (inclusive) such that their sum of digits is divisible by K.
 
Examples
# Input Output
1 100 3 33
2 22 4 5

ID 2963. Processing of entered numbers - 4
Темы: while loop   

A sequence of integers is entered until two equal numbers are entered in a row. Count the number of numbers in a sequence (including the last two).
 
Login Example
3
5
24
4
3
5
3
5
3
5
5
 
Sample output
11

ID 24686. Analysis of the digits of a number - 1
Темы: while loop   

Given a natural number N (N<=109). Determine the ordinal number of its minimum digit, counting from the end of the number (if there are several such digits, then print the number of the first of them)

Input and output example

test number Input Output
1 45545 2
2 100 1
.

ID 31862. The sum of the elements of the sequence
Темы: while loop   

The input of the program receives a data stream — a sequence of integers that ends in zero (zero is not included in the sequence). It is required to find the sum of the elements of this sequence.

Input
The input to the program is numbers, one number per line.

Imprint
Print the answer to the problem.
 

 

Examples
# Input Output
1 1
2
3
0
6

 

ID 38138. Year of the Cow
Темы: while loop    Simulation tasks   

The Chinese calendar is known to follow a 12-year cycle: Ox(Ox), Tiger(Tiger), Rabbit(Rabbit), Dragon(Dragon), Snake(Snake), Horse(Horse), Goat(Goat) , Monkey(Monkey), Rooster(Rooster), Dog(Dog), Pig(Pig), Rat(Rat), and then Ox again. 
For many years, Besi the cow has been proud that she was born in the year of the Ox. Her friend Elsa wants to know how many years her birth is from Besie's and hopes you can help her find it out based on the relationship between the birth dates of some of the cows on the farm.



Input
The first line of input contains an integer N (\(1<=N<=100\)). Each of the following N lines contains an 8-word phrase indicating the relationship between the birth dates of the two cows. In the following form

"Mildred born in previous Dragon year from Bessie",

or

"Mildred born in next Dragon year from Bessie" (previous - previous, next-next).

The last word is the name of the cow, which is either Bessie or the cow previously mentioned in the previous input line.
The first word is the name of a cow that is not Bessie and has not yet been mentioned in the input. All cow names have a maximum of 10 characters a..z or A..Z.

The 5th word is one of the zodiac signs mentioned earlier.

4th word or "previous" or "next". For example, the phrase "Mildred born in previous Dragon year from Bessie", means that the year of birth of Mildred was the year of the Dragon (Dragon), the closest and strictly earlier (not equal) to the year of Bessie's birth.



Imprint
Output the number of years by which the birthdays of Besya and Elsa differ. It is guaranteed that this number can be determined from the input.
 
 
Examples
# Input Output Note
1 4
Mildred born in previous Dragon year from Bessie
Gretta born in previous Monkey year from Mildred
Elsie born in next Ox year from Gretta
Paulina born in next Dog year from Bessie
12

In the example above

  • Elsie was born 12 years before Bessie.
  • Mildred was born 9 years before Bessie.
  • Gretta was born 17 years before Bessie.
  • Paulina was born 9 years before Bessie.

ID 38257. Too much caffeine
Темы: Strings    while loop   

Arthur was always very afraid to meet girls. It's not even about Arthur's natural shyness, and not even so much about the fact that Arthur doesn't know what to talk about with girls. It’s just that Arthur hasn’t pronounced the letter “p” since childhood; and is very shy about it. Therefore, Arthur tries not to utter words once again that contain this hated letter.

One day, friends introduced Arthur to a girl named Nina (oh, what a beautiful name!). She was charming and very talkative, so Arthur hardly needed to find the words — she filled the awkward silence for him. Of course, he invited her to a cafe for a cup of coffee. Arthur even thought through all his lines in advance: "Happy to see you," "You're amazing today," "Yes, of course, I'm listening to you carefully," "What's next?", "The bill, please." and, of course, "I'll call you one of these days, don't be bored."

But, as you know, there are no ideal plans. Everything went like clockwork, but suddenly, sitting at a table in a cafe, Nina said that she had not slept terribly and would not refuse N cups of coffee. And then Arthur realized that he had not thought in advance how he would order. It's understandable to say something like, "How many cups of coffee, please?" Obviously you need to order at least N + 1 cup — so that Nina gets N cups, and drink it herself, but here's exactly how much — Arthur doesn't know. He doesn't have much money, so he doesn't want to order more than what is vital to avoid exposure.

Help Arthur — count how many cups of coffee he should order.

Input
One integer N is entered (1 ≤ N ≤ 2999).

Imprint
Print one number — the number of cups of coffee that Arthur should order.

Examples
# Input Output
1 1 2
2 12 15

ID 38328. Sequences
Темы: while loop   

Consider sequences of numbers. The first sequence consists of one number K. Each next sequence of numbers describes the previous one according to this rule.

We look through the described sequence from left to right and divide it into segments consisting of consecutive equal numbers (moreover, we always combine all identical numbers in a row into one segment). Further, each such segment is described by two numbers — the first number tells how many times the same number is repeated, the second number tells which number is repeated. We write these pairs sequentially in accordance with the segments from left to right, and we get a new sequence (see examples below).

For example, for K=2, the sequences will look like this:

# Sequence How to read it (the words in the description correspond to the numbers of the current sequence from left to right, and describe the previous sequence)
1 2 Source sequence
2 1 2 One "two"
3 1 1 1 2 One "one", one "two"
4 3 1 1 2 Three 1s, one 2
5 1 3 2 1 1 2 One 3, two 1s, one 2
6 1 1 1 3 1 2 2 1 1 2 One 1, one 3, one 2, two 1s, one 2

Write a program that, given the initial number K, will print the Nth resulting sequence.

Input
The number K (1 ≤ K ≤ 9) and the number N (1 ≤ N ≤ 15) are entered.

Imprint
Your program should print the Nth sequence obtained from the initial sequence consisting of a single number K. The numbers should be separated by spaces when outputting.
 
Examples
# Input Output
1 2
6
1 1 1 3 1 2 2 1 1 2 
2 2
1
2
3 1
3
2 1

ID 34851. Leapfrog
Темы: while loop    Greedy Algorithm   

The path is paved with tiles in one row, the tiles are numbered from 1 to 1000. On the tiles with numbers A, B and C (A < B < C) there are three grasshoppers who play leapfrog according to the following rules:
1. Only one grasshopper can be placed on one tile.
2. In one move, one of the two outer grasshoppers (that is, from tile A or from tile C) can jump over the middle grasshopper (tile B) and stand on a tile that is exactly in the middle between the two remaining grasshoppers (that is, between B and C or A and B respectively). If there is an even number of tiles between the two remaining grasshoppers, then he can choose any of the two central tiles.
For example, if the grasshoppers originally sat on tiles number 1, 5, 10, then on the first move, the grasshopper from tile number 10 can jump to tile number 3 (it is in the middle between 1 and 5), or the grasshopper from tile number 1 can jump to tile number 7 or 8 (these two tiles are in the middle between tiles 5 and 10).
Three numbers are given: A, B, C. Determine the maximum number of moves the game can go on.

Input data format
The program receives as input three integers A, B and C (1 <= A < B < C <= 1000) written on separate lines.
Output data format
Print one number — the maximum number of moves that the game can go on.
 

Input Output Note
1
4
6
2 In the example, first the grasshopper jumps from tile 6 to tile 3. Then the grasshopper jumps from tile 4 to tile 2.

ID 34775. Governing Council
Темы: while loop   

The governing council of the school includes parents, teachers and students of the school, and parents must be at least one third of the total number of members of the council. At the moment, the council includes N people, including K parents. Determine how many parents need to be added to the council so that their number becomes at least a third of the number of council members.
The program receives as input two integers N and K (N > 0, 0 ≤ K ≤ N), written in separate lines, — the current number of council members and the number of parents on the council.
The program should output a single number — the minimum number of parents to be included in the council.
 

Input Output Note
27
7
3 In the example, the council consists of 27 people, of which 7 people are parents. If 3 more parents are added to the council, then the council will have 30 people, of which there will be 10 parents.

ID 38431. funny game
Темы: while loop    Binary number system   

The legendary math teacher Yuri Petrovich came up with a fun game with numbers. Namely, taking an arbitrary integer, he translates it into a binary number system, getting some sequence of zeros and ones, starting with one. (For example, decimal 1910 = 1·24+0·23+0·22+1·21 +1·20 in binary system will be written as 100112.) Then the teacher starts shifting the digits of the resulting binary number around the cycle (so that the last digit becomes the first , and all the rest are shifted one position to the right), writing out the resulting sequences of zeros and ones in the column — he noticed that regardless of the choice of the initial number, the resulting sequences begin to repeat from a certain moment. And, finally, Yuri Petrovich finds the maximum of the numbers written out and translates it back into the decimal number system, considering this number the result of the manipulations done. So, for the number 19, the list of sequences would be:
10011
11001
11100
01110
00111
10011

and the result of the game will therefore be the number 1·24+1·23+1·22+0·2 1+0·20 = 28.

Since the invented game with numbers takes more and more of the teacher's imagination, thereby distracting him from working with very gifted schoolchildren, you are asked to write a program that would help Yuri Petrovich get the result of the game without tedious manual calculations.
Input format
The input file contains one integer N (0 ≤ N ≤ 32767).
Output format
Your program should print to the output file a single integer equal to the result of the game.

Examples
# Input Output
1 19 28

ID 38627. Number Cookies
Темы: Whole numbers    while loop    Conditional operator   

Gromozeka loves number cookies. Among all the numerical cookies, Gromozek eats only those on which the sum of the digits of the written number in the decimal number system is a divisor of the number itself. You are given a number written on a cookie. Determine whether Gromozeka will eat it or not.

Input
The input is an integer N (1<=N<=109).

Imprint
Print Yes if Gromozeka will eat such a cookie, No  if not.
 

 

Examples
# Input Output
1 12 Yes
2 101 No

 

ID 38714. The difference in the number of candies
Темы: while loop    for loop   

You have N bags of candy. There are some candies in each bag of . Determine the maximum difference between the number of candies of any two bags.

Input
The first line contains an integer N (1<=N<=100). The second line contains N numbers ai (1<=ai<=109 ) - number of candies in  i-th bag.

Imprint
Print the maximum difference between the number of candies of any two bags.
 

Examples
# Input Output
1 4
1 4 6 3
5
2 5
1 1 1 1 1
0

ID 38731. Minimum divisor
Темы: Prime numbers and factorization    while loop   

Find the smallest natural divisor of x other than 1 (2 <= x <= 30000).

Input
A natural number x is entered.

Imprint
Print the smallest divisor of x that is different from 1.

Examples
# Input Output
1 6 2

ID 38739. Zero or not zero
Темы: while loop   

Check if data N numbers contains zeros.


Input

Enter a number N followed by numbers.


Output

Print YES if there is at least one zero among the entered numbers, or NO otherwise.

Examples

# Input Output
1 3
4
19
14
 
NO

ID 38874. Various squares
Темы: while loop   

Petya has n unit squares. He wants to add as many different squares as possible from them at the same time. It takes k2 unit squares to fold a square of side k. Petya may not use all the squares he has.
Determine the maximum number of squares Petya can add.

Input
The input is an integer n (1 ≤ n ≤ 1018). Note that a 64-bit data type is required to store such a number (int64 in Pascal, long long in C++).

Imprint
Print one number — the maximum number of different squares that Petya can add.
 

Examples
# Input Output
1 10 2

ID 39064. Maximum Sequence
Темы: while loop   

The sequence consists of natural numbers not exceeding 109 and ends with the number 0. Determine the value of the largest element in the sequence.


Input
A sequence of integers is entered, ending with the number 0 (the number 0 itself is not included in the sequence, but serves as a sign of its end).

Imprint
Print the answer to the problem.
 
Examples
# Input Output
1 2
6
9
8
0
9

ID 39065. Two identical numbers side by side
Темы: while loop   

Write a program that determines if a given number contains two identical digits side by side (such as 221).


Input
The program receives as input one natural number N (N > 9).


Imprint
The program should output the word 'YES' if the number has two identical digits side by side, and the word 'NO' , if there is no such pair of digits.

 
Examples
# Input Output
1 1221 YES
2 123 NO

ID 40063. Slimes
Темы: while loop   

Gromozeka has A slimes. Each time Gromozeka sneezes, the number of slimes increases by K times. What is the minimum number of times Gromozeka needs to sneeze to get B or more slimes?


Input
The input is three positive integers A, B (1 <= A <= B <= 109), K< /code> (2 <= K <= 109).  

Imprint
Display the answer to the problem
 

Examples
# Input Output
1
1 4 2
2
2
31 415926 5
6

ID 42244. Aquarius
Темы: Cycles    while loop   

The performer “Aquarius” there are two vessels, the first with a volume of A liters, the second with a volume of B liters, as well as a tap with water. Aquarius can perform the following operations:

  1. Fill vessel A (indicated by >A).
  2. Fill vessel B (indicated by >B).
  3. Pour water out of vessel A (denoted by A>).
  4. Pour water out of vessel B (denoted by B>).
  5. Pour water from vessel A into vessel B (denoted as A>B).
  6. Pour water from vessel B into vessel A (denoted as B>A).

The command to pour from one vessel to another results in either the first vessel being completely emptied or the second vessel being completely filled.



Input
The program receives as input three natural numbers A, B, N not exceeding 104.

Output

It is necessary to display the Aquarius action algorithm, which allows you to get exactly N liters in one of the vessels, but if such an algorithm does not exist, then the program should display the text Impossible.< /p>

The number of operations in the algorithm should not exceed 105. It is guaranteed that if the problem has a solution, then there is a solution that contains no more than 105 operations.

 
Examples
# Input Output
1
3
5
1
>A
A>B
>A
A>B
2
3
5
6
Impossible

ID 42972. tasty number
Темы: while loop   

Gromozeka considers a natural number delicious if all its digits are distinct and the sum of its digits is equal to the number written on the cookie that Gromozeka eats.
Now Gromozeka is eating a cookie with the number n written on it. Help him find the smallest tasty number for such a cookie.
For example, if n = 10, then the smallest tasty number is 19 (1+9=10, all digits of 19 are different).

Input
The program takes as input an integer n (1 <= n <= 45).

Imprint
Print the answer to the problem.
 
 

Examples
# Input Output
1 10 19
2 1 1