Maximum product (DP + high precision)
Title Link https://www.luogu.com.cn/problem/P1018
This year is the "2000 - world year of mathematics" determined by the International Mathematical Union, and coincides with the 90th anniversary of the birth of Mr. Hua Luogeng, a famous mathematician in China. In Jintan, Jiangsu, Mr. Hua Luogeng's hometown, a new mathematical intellig ...
Posted by Hiro on Thu, 17 Feb 2022 21:25:04 +0100
Luogu P1926 little schoolboy - question brushing Army
P1926. Little schoolboy - question brushing Army
subject
Topic background
Mathematics is fire, lighting up the lamp of physics; Physics is a lamp, illuminating the way of chemistry; Chemistry is the road leading to the pit of biology; A creature is a pit, burying a man of reason. Classical Chinese is fire, lighting up the palace lamp of hist ...
Posted by eddiegster on Thu, 17 Feb 2022 08:48:27 +0100
SDNU_ACM_ICPC_2022_Winter_Practice_4th [individual]
A
A - A Funny Game
Meaning: n coins form a circle. Each round can take away one or two adjacent coins. Finally, the player who takes all the coins wins. Alice took the lead and asked who would win.
Idea: when n < = 2, Alice can take it all at once, and Alice will win; When n > = 3, no matter Alice takes 1 or 2 coins, Bob can take the c ...
Posted by travelkind on Mon, 14 Feb 2022 16:56:17 +0100
[leetcode question brushing day 34] 540 Unique element in array, 384 Disrupt array, 202 Happy number, 149 Maximum number of points on a line
Day 34
540 a single element in an ordered array
Give you an ordered array of integers, where each element will appear twice and only one number will appear once.
Please find and return the number that appears only once.
The solution you design must meet O(log n) time complexity and O(1) space complexity.
method
Since all elements in the a ...
Posted by atyndall on Mon, 14 Feb 2022 14:33:23 +0100
JAVA exercise 114 - cat and mouse
The two players play the role of cat and mouse respectively, and play the game on an undirected graph. They take turns.
The form of graph is: graph[a] is a list, which is composed of all nodes b satisfying that ab is an edge in the graph.
The mouse starts from node 1 and starts first; The cat starts from node 2 and starts the second. There is ...
Posted by drunknbass on Sat, 12 Feb 2022 13:22:55 +0100
Three solutions to change in Python
Change
The most direct solution to the change problem is the greedy strategy. For example: for coins with face values of 1, 5, 10 and 25, solve the minimum number of coins required to exchange 63 yuan.
The idea of greedy strategy is to constantly use the coins with the largest face value to try. No, in this case, 25 coins are used to try the ...
Posted by dbrimlow on Sat, 12 Feb 2022 08:55:23 +0100
Summary of dynamic programming of leetcode 3
Summary of dynamic programming of leetcode 3
1 - house raiding Title Link: Title Link stamp here!!!
Idea: the idea of this question is not difficult, but we need to pay attention to the details. Recurrence formula: DP [i] = max (DP [I-1], DP [I-2] + num [i])
class Solution {
public int rob(int[] nums) {
if(nums.length==1){
...
Posted by dwnz on Sat, 12 Feb 2022 03:49:12 +0100
Educational Codeforces Round 109 (Rated for Div. 2) D. Armchairs (dp)
Link Title: https://codeforces.com/contest/1525/problem/D
Main idea of the title:
0,1 sequence of numbers, a[i]=0 or 1. The number of 1 must not exceed half of n. We need to pair all 1s with a 0. A 0 can only be paired with a 1 ifandPairing will consumeResources. What is the minimum total resource consumption after all 1s are paired?
Solutio ...
Posted by a.beam.reach on Sat, 12 Feb 2022 00:57:10 +0100
Sword finger offer89: House theft
Title: A professional thief plans to steal houses along the street. There is a certain amount of cash hidden in each room. The only restrictive factor affecting the thief's theft is that the adjacent houses are equipped with interconnected anti-theft systems. If two adjacent houses are intruded by thieves on the same night, the system will auto ...
Posted by zipp on Fri, 11 Feb 2022 15:53:42 +0100
[data structure and algorithm] in-depth analysis of the solution idea and algorithm example of "maximum Rectangle"
1, Title Requirements
Given a two-dimensional binary matrix containing only 0 and 1 and the size of rows x cols, find the largest rectangle containing only 1 and return its area.Example 1:
Input: matrix = [["1","0","1","0","0"],["1","0","1","1","1"],["1","1","1","1","1"],["1","0","0","1","0"]]
Output: 6
Example 2:
Input: matrix = []
Outp ...
Posted by solarisuser on Fri, 11 Feb 2022 15:49:53 +0100