Middle Multiple(s) of 10

 Coding Problem Keys 

 Middle Multiple(s) of 10 

 Problem Statement 

The program must accept two integers M and N as the input. The program must print the middle multiple of 10 among the multiples of 10 from M to N. If the number of multiples is even, the program must print the middle two multiples of 10 as the output. If there is no multiple of 10 from X to Y, the program must print -1 as the output.

 Boundary Condition(S) 

1 <= M < N <= 10

 Input Format 

The first line contains M and N separated by a space.

 Output Format 

The first line contains the integer value(s) as per the given conditions.

 Example Input/Output 1 

 Input 

45 96

 Output 

70

 Explanation 

The multiples of 10 from 45 to 96 are 50, 60, 70, 80 and 90.
Here the middle multiples of 10 is 70.
Hence the output is 70.

 Example Input/Output 2 

 Input 

110 140

 Output 

120 130

 Explanation 

The multiples of 10 from 110 to 140 are 110120130 and 140.
Here number of multiples of 10 is even. So the middle two multiples of 10 are 120 and 130.
Hence the output is 120 130.

 Example Input/Output 3 

 Input 

1022 1029

 Output 

-1

 Note: Max Execution Time Limit: 500 millisecs 

 Solution 

 Programming Language: Python 3 Language 

m,n=map(int,input().split())
s=[]
for i in range(m,n+1):
    if(i%10==0):
        s.append(i)
k=len(s)
if(len(s)==0): print("-1")
elif(k%2==0): print(s[k//2-1],s[k//2])
elif(k%2!=0): print(s[k//2])

# Published By PKJCODERS

 (Note: Incase If the code doesn't Pass the output kindly comment us with your feedback to help us improvise.) 

Comments

SB said…
Thanks for sharing this post with us.Filmydost

Popular Posts

Top Scoring Batsman - TEST ODI 20-20

Largest Possible Number With Digits

Highly Profitable Months

Minimum Sum of Non-Negative Elements

Count Embedded Integers in String

String - Vowels Position Sum

Desktop Products