Chect out this problem i made myself, i could not solve it.

Revision en1, by comingsoon.cpp, 2025-03-01 09:51:13

A number is called a safe number if except for the first and last digit digits, each digit is less than the average of it's two adjacent digits, i.e ai < ((ai-1 + ai+1)/2). Examples, 223,137,429 and 53247 are all safe numbers, while 123, 2312, 321 and 54257 are not safe numbers. Now i have two problems.

The first problem, you are given an integer n, you task is to count the number of safe numbers that are less than or equal to n.

The second problem, you are given an integer n, you task is to find the nth largest safe number.

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English comingsoon.cpp 2025-03-01 09:51:13 597 Initial revision (published)