[Codeforces div3-498] problem solution
Codeforces div3-498 Problem solution
A. Adjacent Replacements
The problem is relatively simple. If the number N is an odd number, it will remain unchanged after transformation. If the number is an even number, it will become N - 1
#include <stdio.h>
const int maxn=1005;
int a[maxn];
int n;
void work()
{
scanf("%d",&n);
for( ...
Posted by Matt Phelps on Sun, 09 Jan 2022 13:30:10 +0100
machine learning in action learning notes of machine learning algorithm classification method based on probability theory: Naive Bayes
Classification method based on probability theory: Naive Bayes
Advantages: it is still effective in the case of less data (but the accuracy is also inexhaustible), and can deal with multi category problems.
Disadvantages: it is sensitive to the way data is input.
Applicable data type: nominal data.
Pre knowledge: conditional probability, Bay ...
Posted by ayed on Sun, 09 Jan 2022 12:07:51 +0100
[NOIP2007] string expansion
Source: Niuke network
Time limit: 1 second for C / C + + and 2 seconds for other languages Space limitation: C/C++ 262144K, Other languages 524288K 64bit IO Format:%lld
Title Description
In the problem of "reading program writing results" of the preliminary popularity group, we gave an example of string expansion: if the inp ...
Posted by Bauer418 on Sun, 09 Jan 2022 11:04:36 +0100
Six basic sorting
Six basic sorting
Learning records
I Simple sort
1.1 bubble sorting
It means that two adjacent elements are compared, and the largest element is selected at each time and placed on the last side
package sort;
/**
* Bubble sorting
* It means that two adjacent elements are compared, and the largest element is selected at each time and pla ...
Posted by TRemmie on Sun, 09 Jan 2022 10:59:07 +0100
Fall in love with data structures and algorithms course notes for the third quarter 01
Note: some drawing parameters come from network resources
1._ 88 merge two ordered arrays
Label: merge sort, three pointers
Idea: set three pointers to point to the tail i1 of the actual array, the array i2 and the tail i3 of the overall array.
Compare the values pointed to by i1 and i2 every time. If i2 > i1, exchange the value pointe ...
Posted by HowdeeDoodee on Sun, 09 Jan 2022 10:08:53 +0100
The left hand and the right hand are (not) from left inverse to right inverse generalized inverse to solving the least squares solution of linear equations
preface
I finally finished my final homework, I can't catch me (No. last time I talked about solving linear equations by LU decomposition, but sometimes when the equations are incompatible, the conventional method will fail. At this time, we can use the least square method. Of course, for matrix fitting, we can directly calculate th ...
Posted by mo0ness on Sun, 09 Jan 2022 09:46:41 +0100
On dynamic programming and dfs
prefaceIt is still necessary to learn the front-end algorithm. Not to mention that large factories test the algorithm in interviews, but when doing the permission module, if you don't understand the algorithm, you can't write the user-defined traversal of the tree structure.Today, I will make a summary of the dynamic programming and dfs encount ...
Posted by anhedonia on Sun, 09 Jan 2022 06:34:48 +0100
Implementation of sword finger offer go version Chapter 5: optimizing time and space efficiency
Main purpose of this chapter
Although the main purpose of this chapter is to optimize time and space, we all know that this is our most troublesome optimization, because various principles and implementation methods are difficult to understand and innovate. Even the schemes proposed by predecessors are still difficult to implement in code or e ...
Posted by klycette on Sun, 09 Jan 2022 04:49:31 +0100
Is a shareholder of the company
Title Description
You are given two integer arrays nums1 and nums2 in non decreasing order, and two integers m and n representing the number of elements in nums1 and nums2 respectively. Please merge nums2 into nums1 so that the merged array is also arranged in non decreasing order.
Title Example
Example 1:
Input: nums1 = [1,2,3,0,0,0], ...
Posted by nschmutz on Sun, 09 Jan 2022 04:20:18 +0100
[Warrior's notes] sword finger offer 32 Three questions, let you learn the depth and breadth first traversal and recursive iterative techniques of binary tree
Title one sword refers to Offer 32 - I. print binary tree from top to bottom
Source: LeetCode
Link: https://leetcode-cn.com/problems/cong-shang-dao-xia-da-yin-er-cha-shu-lcof/
1. Description
Each node of the binary tree is printed from top to bottom, and the nodes of the same layer are printed from left to right.
2. Examples
Example 1:
Given ...
Posted by lavender on Sun, 09 Jan 2022 00:51:29 +0100