Tag：positive integer

Digital DP1012. At least 1 repeated digit
Problem Description Given a positive integer n, return the number of positive integers with at least 1 repeated digit in the range [1, n]. Example 1: Input: n = 20output: 1Explanation: Positive numbers (<= 20) with at least 1 repeated digit are only 11.Example 2: Input: n = 100output: 10Explanation: Positive numbers (<= 100) with […]

Digital DP902. Number combinations up to N
Problem Description Given an array digits of digits in nondecreasing order. A number you can write with digits[i] any number of times. For example, if digits = ['1','3','5'], we can write digits like '13', '551', and '1351315'. Returns the number of positive integers that can be generated that are less than or equal to the […]

Four squares and pruning + enumeration [Blue Bridge Zhenti] (c++)
sum of four squares The Sum of Four Squares Theorem, also known as Lagrange's Theorem: Every positive integer can be represented as the sum of squares of up to 4 positive integers.If you include 0, it can be expressed as the sum of the squares of 4 numbers. for example:5 = 0^2 + 0^2 + […]

Meituan backend written test
Article directory After the whole written test, the overall difficulty is average, but the third question of the poker game was not very smooth, and the difficulty of the additional questions was average. I don’t know if there are any friends who spend the same time on the third question as I do. 1. Magic […]

AM: Birthday (basic computer test questions)
Xiao Ming was born in a leap year, he wants to know when his birthday can be celebrated, can you tell him?Given a positive integer Y, representing the starting year, and a positive integer N, your task is to tell Xiao Ming which year is the Nth leap year starting from year Y.Note: If Y […]

AR: Square String
Now please output the "ACM" string of the specified size. In particular, we require that the output string be square (equal number of rows and columns).enterThe first line of input is a positive integer N (N<=20), indicating that there are N groups of data, followed by N lines of data, each line contains a positive […]

[recursive topics] be: tiling, bf: statistical scheme, bg: Xiaoming’s pig raising story, bh: Xiaoming’s troubles
In this part, I feel like finding a law. Finding the expression of mathematical law is very easy to complete this kind of problem, so don’t rush to write code when encountering recursion, find the law first! One piece is 2 in sizeThe wall of n now needs to be covered with 2 kinds of […]

Use of sync.waitgroup in golang
Waitgroup is a commonly used synchronization blocking wait object. Waitgroup can schedule goroutinue. First, call the add (Num) of the synchronous wait group, where num is a positive integer, and num will be added to the counter data in the waitgroup. Then, call done() inside the workflow, and the do() method calls add (1). The […]

DP problem of path counting dynamic programming
Problem description Input format Output format Example code supplement The problem solution analysis is easy to fill in (Doge), and slowly update ing Path count It is a classic and common dynamic programming DP topic Problem description There is onen×n”>n×nSome grids are passable, and some grids are obstacles. At the beginning, when you are […]

[number theory topic] btby (basic computer test)
Bt: beautiful number Xiao Ming likes the numbers 3 and 5 very much. He calls the numbers that can be divided by 3 or 5 beautiful numbers. Now let me give you an integer n (1 < =n < =100000). Can you tell Xiao Ming what the nth beautiful number is?Prompt that this problem needs […]

The kth missing positive integer of leetcode
order This paper mainly records the kth missing positive integer of leetcode subject Give you a strictly ascending array of positive integers arr and an integer K. Please find the kth missing positive integer in this array. Example 1: Input: arr = [2,3,4,7,11], k = 5 Output: 9 Explanation: missing positive integers include [1,5,6,8,9,10,12,13,…]. […]

[special topic of number theory] finding prime pairs, a/b + c/d
Find prime pairs Goldbach guesses that everyone knows a little Now we don’t want to prove this conclusion, but we want to take an even number out of the number set that can be expressed in the program language to find two prime numbers, so that the sum is equal to the even numberIf this […]