Блог пользователя comingsoon.cpp

Автор comingsoon.cpp, история, 6 часов назад, По-английски

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.

  • Проголосовать: нравится
  • -5
  • Проголосовать: не нравится

»
6 часов назад, # |
Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

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