- 博客(27)
- 收藏
- 关注
原创 AcWing 868.Choose PrimeNumber(PrimeNumber) Described by Java
To counter the number of Prime number between 1 - n.The mainly is to delete the number and its multiple.Problem in AcWingSimply codeThe time complexity is the O(nlogn) (Harmonic series)We need t...
2019-11-30 07:00:20 95
原创 AcWing 867.Factorization Factor(PrimeNumber) Described by Java
This is to factor a number quickly, if can done successfully the last problem, this is easy.Problem in AcWingMy WA code :import java.io.BufferedReader;import java.io.IOException;import java.io.In...
2019-11-29 06:39:37 200
原创 AcWing 866.PrimeNumber (PrimeNumber) Described by Java
Now we will learn the Number Theory in ACM.This article is about how to judge a prime number quickly.Problem in AcWingNormal thinkingfor (int i = 2; i < (n >> 1); i++) if (n % i == 0) re...
2019-11-29 04:26:09 163
原创 AcWing 861.Maximun Matching of Bi-PartiteGraph (Bi-PartiteGraph) Described by Java
Last of the graph part.Problem in AcWingIt’s an algorithm like finding a girl friend, if one has a boy with her, try to let that boy to find another girl, if can, do it, else then, it’s her. This i...
2019-11-29 00:02:07 166
原创 AcWing 859. Kruskal-Minimum Spanning Tree (Kruskal) Described by Java
Kruskal is simpler than Prim, and easy to write.First step to sort the value by ascending orderAnd then check if the two points is not in one set, if it is, connect them, like union-find algorithm....
2019-11-27 05:13:02 109
原创 AcWing 858. Prim Minimum spanning tree(Prim) Described by Java
What is the minimun spanning tree?A minimum spanning tree (MST) or minimum weight spanning tree is a subset of the edges of a connected, edge-weighted undirected graph that connects all the vertices ...
2019-11-25 03:47:56 89
原创 AcWing 854. Floyd Shortest Path (Floyd) Described by Java
What is Floyd?The Floyd algorithm, also known as the interpolation method, is an algorithm that uses the idea of dynamic programming to find the shortest path between multiple source points in a give...
2019-11-24 22:26:15 127
原创 AcWing 852. SPFA to judge negative loop(SPFA) Described by Java
Now use SPFA to judge if there has a negative loop in a graph.Add an array cnt[] to count the current point to index point , how many edges will be passed?And a new question is why the queue writte...
2019-11-24 19:08:22 85
原创 AcWing 853. Shortest path with edges limited (Bellman-ford) C++
Used to describe with Java.Go to Java#include <bits/stdc++.h>using namespace std;const int N = 5e2 + 10, M = 1e4 + 10;int dist[N], backup[N];bool st[N];int n, m, k;struct Edge { in...
2019-11-23 17:23:05 131
原创 AcWing 851. Shortest path solved by SPFA (SPFA) Described by Java
Last picture we saw such kind of ways to solve the shortest path.Now is SPFA, simple, save by queue, and more stable.Problem in AcWingThe st[] is to record if a point is in queue.import java.io.Bu...
2019-11-23 17:17:53 124
原创 AcWing 853. Shortest path with edges limited (Bellman-ford) Described by Java
This is a module of Bellman-ford, we can see the problem first.Problem Bellman-ford in AcWingThis is also a graph problem, only difference is it will has negative value, so we cannot use Dijkstra to...
2019-11-23 05:26:50 120
原创 AcWing 850. DijkstraⅡ(Dijkstra) Described by Java
This has more points, is sparse graph.So we use adjacency table to save.The pic can not upload successful…Problem in AcWingsame , turn the adjacency matrix to table.And using the PriorityQueue to...
2019-11-22 21:48:50 123
原创 AcWing 849. Dijkstra Ⅰ (Dijkstra algotithm) Described by Java
This is the simple Dijkstra module.AcWing in AcWingUsing more than 2 hours to debug , last other guys told me that u must use long to instead of integer… fuck me.import java.io.*;import java.util....
2019-11-22 06:22:35 143
原创 AcWing 848.Directly graph's topology sequence (BFS) Described by Java
Cause of this semester we will do the single chip microcomputer, It’s very very difficult, using C to program. I hope I will pass the Exam and Project! And maybe have not a long time to practice, but ...
2019-11-22 06:16:01 93
原创 AcWing 847.Level of points in the graph (bfs with tree) Described by Java
So this article is about bfs with tree. A module.Problem in AcWingLike the BFS, this problem is a naked problem.import java.io.BufferedReader;import java.io.InputStreamReader;import java.io.Print...
2019-11-17 03:14:53 91
原创 AcWing 846.The center of gravity of the tree(dfs with tree) Described by Java
This module is about using bfs with tree, same principle.Problem in AcWingLike a list, each block we deal with each stack.Code :import java.io.BufferedReader;import java.io.IOException;import j...
2019-11-13 21:43:04 99
原创 AcWing AcWing 845. 8-grid shift(bfs) Described by Java
Fuck the problem debugging more than two hours , fuck u, u sick fuck.And finally I got the principle(module) of the fucking BFS. It fucked me a long time.The damn Problem in AcWingI can write the m...
2019-11-11 06:52:21 122
原创 AcWing 844. Go through the maze(bfs) Described by Java
Classic problem in AcWingBFS Module.And write the Queue in array and Pair<Integer, Integer> in Java.The Code :import java.io.BufferedReader;import java.io.IOException;import java.io.InputS...
2019-11-10 23:21:17 251
原创 AcWing 843. N-Queens(DFS) Described by Java
Classic problem-N-Queens Problem, using dfs to deal.Dfs always has a module, ago in Summer check-in training had trained it.How to maintain the hypotenuse:And the N-Queens Code :import java.io.Bu...
2019-11-10 18:06:43 91
原创 AcWing 842. Arrange numbers(DFS) Described by Java
Now I start the third chapter, searching and graph.The first module is dfs ,depth-first search.Here we will not talk too much about DFS and BFS theory.Classic Problem in AcWingAnd the DFS code :i...
2019-11-09 23:00:29 82
原创 AcWing 841. String-Hash (String - Hash) Described by Java
Another method on Hash of String , very strange and difficult to think.Firstly we have a browse on Problem in AcWing.The String Hash method is to solve the deal like this kind of problem.Principle:...
2019-11-09 20:32:19 94
原创 AcWing 840. Simulate the HashMap(Hash _ Open Addressing) Described by Java
Problem in AcWingAnd we got the open addressing method to solve the Hash.The Open Addressing does not need too many array, only one.Used to create two to three times size of the problem given.Like...
2019-11-09 06:27:37 93
原创 AcWing 840. Simulate the HashMap(Hash) Described by Java
The lecture we train the Hash Algorithm, and using the array.The discretization is the special case of Hash, cause of the discretization has special order, and the Hash is hash, no orders.Like the t...
2019-11-08 23:32:11 97
原创 838. Heapsort(Module HeapSort) Described by Java
Now we can note module of HeapSort.The problem.Problem in AcWingThe problem is to print the minimal k number, it’s easy to change the output when we need. The Time Complexity is O(nlogn).And the C...
2019-11-07 23:23:40 195
原创 AcWing 240. 食物链(Weighted disjoint set union) Described by Java
A difficult problem is about weighted disjoint set union, to maintain another array distance[] to describe the distance from x to p[x].And the problem. ProblemLike a tree , the distance from the l...
2019-11-07 18:32:38 279
原创 AcWing 837. 连通块中点的数量(disjoint set union) Described by Java
Now we still train the disjoint set union.The last module:import java.util.Arrays;import java.util.Scanner;public class Main { static int pre[]; static int n; static int m, a, b; st...
2019-11-06 06:44:44 150
原创 AcWing 143. 最大异或对(Trie) Described by Java
After traveling from Stockholm and Uppsala , I must come on and train some more.Today training is still Trie Tree , The Trie not only can save the words , also can save the numbers, so it can save an...
2019-11-05 20:04:40 130
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人