HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Volumes > Functions > problem:


50917 - Descending Numbers

Guest
• Review clarifications (1)

Volume problems

• 50911 - Symmetric Array
• 50296 - Total Discount Rate
• 50935 - Max Discount
• 50851 - Repeated Numbers
• 50838 - Balanced Numbers
• 50724 - Number of Circles
• 50916 - Ascending Numbers
• 50926 - School Mail Merge
• 50917 - Descending Numbers
• 50982 - A thief in labyrinth
• 50980 - The smallest rectangle
• 50932 - Shifting rows and columns
• 50933 - Sum of the Biggest Neighbors
• 50834 - The train which leaves the f...
• 51003 - Double Prime
• 50435 - City Electric Bills
• 50527 - Sum of LCMs

Feedback

If you notice incorrect translations in Contester, please let author know.

Time limit 2000/4000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb.
Question by Ibrahim Mesecan.

Descending Numbers

Descending numbers are

  • at least two digits numbers
  • whose last digit is one of the smallest digits and
  • all its digits are in descending order (smaller than or equal to the previous digit).
For example: 321, 32211 and 221111 are descending numbers. But the following are not descending numbers:
  • 3121: because there is 2 after 1
  • 42223: because there is 3 after 2
  • 111111: because all digits are the same (last digit is not the smaller than any other).

Question: Write a program that takes n numbers. Then, it counts and shows the number of descending numbers.
Note: If needed, you can use the following functions from #include "utils/functions.h"
 int numDigits(int num); // which returns the number of digits of the given number
 int getDigit(int num, int k); // which returns kth digit of the given number where k=1 is the least significant digit

Input specification
You will be given an integer in the beginning: the number of numbers (n). Then, in the following n lines you will be given n numbers where 0 ≤ n ≤ 40,000 and the numbers are at most 16 digit integers.

Output specification:
Show the number of descending numbers.

Sample Input I
10
941
7
761
705
1122
543
489
46043
4677
3057
Sample Output I
3

Explanation:
There are 3 descending numbers in the list: 941, 543, and 761.



Для отправки решений необходимо выполнить вход.

www.contester.ru