comingsoon.cpp's blog

By comingsoon.cpp, history, 6 hours ago, In English

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.

  • Vote: I like it
  • -6
  • Vote: I do not like it

»
6 hours ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

why 223 is a safe number? 2+3/2=2 and a0 equals it. Or avg is not floored?