P3959 treasure

The distance from one point to another is equal to the number of edges.    First select a point and connect it with other points to find the minimum distance. Input sample #1: 4 5 1 2 1 1 3 3 1 4 1 2 3 4 3 4 1 Output sample #1: 4 Input sample #2: 4 5 1 2 1 1 3 3 1 4 1 2 3 4 3 4 2 Output sample #2: 5 Explain   Of course, it’s blasting. #include<cstdio> #include<iostream> #include<cstring> #include<cctype> #include<algorithm> using namespace std; #define int long long int n; int m; int f[20][20]; int g[20]...

1132 Cut Integer

A little bit. Thought: note that the divisor may be 0, otherwise it will cause floating-point error. Code: #include <iostream> #include <string> using namespace std; int main() { int n; string str; cin>>n; while(n--){ cin>>str; string s1=str.substr(0,str.size()/2); string s2=str.substr(str.size()/2,str.size()/2); int a=stoi(s1),b=stoi(s2),val=stoi(str); if(b!=0 && val%(a*b)==0) cout<<"Yes\n"; else cout<<"No\n"; } }  

template engine

Template engine, the word “engine” has always made me feel tall and I want to comb it today. To illustrate its usefulness, click the button to send an Ajax request for background server data, and then display the data in an empty table tag on the Web page Node Small server implemented var http = require('http') var server = http.createServer() server.on('request', function (req, res) { res.setHeader('Access-Control-Allow-Origin','*') //Cross domain resource sharing allows any source request. //jsonArray to simulate database data var data = `[{ "name": "MicKo...

Analysis of STM32 map file

  I believe that friends with greater project development experience have encountered memory overflow problems, so how do you analyze such problems? Have you ever met HardFault_Handler and analyzed map?   First, let’s talk about the configuration of map in MDK-ARM. In fact, in MDK-ARM, we can output the corresponding (we need) content in the map file according to our own circumstances (different configurations). By default, all information is output.   Project -> Options for Target -> Listing:You will see the following configuration interface:   See the above picture, I bel...

String matching “KMP algorithm”

Introduction As we all know, strings have a large proportion in OI and other computer fields. What we are talking about today is an algorithm for matching strings – “KMP algorithm”.   0x00 KMP The algorithm is used to solve such a problem: Given a text string T and a pattern string S, you are required to find the number and position of S appearing in T (we define the position as the position where the first character in S matches in T). Of course, there are many other uses. Specific can be reflected through a topic HDU 3336   0x01 We all know the simple algorithm of matchi...

File manipulation small knowledge points supplement

Some files are too large to read and write directly. They need to read one line by line, using a for loop.# f = open("log", mode="r+", encoding="utf-8")## for line in f:# print(line)## f.close()with open Open file operation can be automatically closed without adding f.close ().# with open("log", mode="r+", encoding="utf-8") as f:# print( f.read())with open("log", mode="r+", encoding="utf-8") as f1,open("123", mode="r+", encoding="utf-8"): f1.read()

Python file object several operation mode difference — file operation method detailed explanation

    Byte mode of file object/b Settings3 set any byte each time. Chinese string Returns a string that can be viewed Write to find string Useseek > Pattern File existence file does not exist operation Document content r Establishopen default isr objects normally open normally. Establishopen objects normally open normally. Establishopen isutf-8 program, read this text file will be wrong, it will use.windows read mode (default).  w. Mode plus‘b’ method returns an integer indicating the current pointer position. f.seek(offset,from_what) sta...

10 typical software development models

1. While doing, change the model (Build-and-Fix Model). 2. The waterfall model (Waterfall Model); 3. Rapid Prototype Model (rapid prototyping); 4. Incremental Model; 5.The spiral model (Spiral Model); 6.Evolution model (evolution model); 7.The fountain model (fountain model); 8.Intelligent model (four generation technology (4GL)); 9.Agile development model (agile development model); 10.RADRapid (Application Development);