Розв'язник вправ по дискретній математиці/Комбінаторика

Розв'язник вправ по дискретній математиці. Комбінаторика ред.

Задача 1 ред.

а) Яких чисел більше серед цілих чисел першої тисячі (включаючи і 1000): в записі яких є одиниця, або інших? б) Яких семизначних чисел більше: тих, в запису яких є одиниця, або інших?

Задача 2 ред.

Скількома способами 3 людини можуть розділити між собою 7 однакових яблук, один апельсин, одну сливу і один мандарин?

Задача 3 ред.

  • Розв'язати завдання з leetcode.com (Count Sorted Vowel Strings). Given an integer n, return the number of strings of length n that consist only of vowels (a, e, i, o, u) and are lexicographically sorted.

A string s is lexicographically sorted if for all valid i, s[i] is the same as or comes before s[i+1] in the alphabet.

Задача 4 ред.

  • Розв'язати завдання з leetcode.com (Pairs of Songs With Total Durations Divisible by 60). You are given a list of songs where the ith song has a duration of time[i] seconds.

Return the number of pairs of songs for which their total duration in seconds is divisible by 60. Formally, we want the number of indices i, j such that i < j with (time[i] + time[j]) % 60 == 0.

Задача 5 ред.

  • Розв'язати завдання з leetcode.com (62. Unique Paths). There is a robot on an m x n grid. The robot is initially located at the top-left corner (i.e., grid[0][0]). The robot tries to move to the bottom-right corner (i.e., grid[m - 1][n - 1]). The robot can only move either down or right at any point in time.

Given the two integers m and n, return the number of possible unique paths that the robot can take to reach the bottom-right corner.