Assignment and initialization

Problems encountered in learning copy deconstruction today:    1 #include <iostream> 2 using std::cout; using std::cin; using std::endl; 3 #include "HasPtr.h" 4 5 int main() 6 { 7 HasPtr ha("Halo"); 8 cout<<ha.getPs()<<endl; 9 HasPtr copy_ha(ha); 10 cout<<copy_ha.getPs()<<endl; 11 H ...

Posted on Tue, 12 Nov 2019 09:04:50 -0500 by j-dearden

Luogu P3381 [[template] minimum cost maximum flow]

Send the network flow, and then send the cost flow If you can do the cost flow, the network flow can do it naturally. But here is Amway's own blog (which also has the problem of the network flow): Point me Far away. Cost flow is to find the minimum cost from the source point to the sink point without exploding the water pipe. Do you think ...

Posted on Mon, 11 Nov 2019 15:39:27 -0500 by uknowho008

[explanation] hdu1506 Largest Rectangle in a Histogram

Catalog subject thinking $Code$ subject Largest Rectangle in a Histogram thinking Monotonic stack. I don't know how to describe it, so I'll give you an example. 7 2 1 4 5 1 3 3 The height of the largest rectangle must be one of the heights given to you. Let's enumerate the maximum heights. Obvious ...

Posted on Mon, 11 Nov 2019 10:20:12 -0500 by dotancohen

CF161B Discounts

Catalog subject thinking $Code$ subject CF161B Discounts thinking Greedy. Obviously, for a bench (the price is c), we can spend the most $\ frac{c}{2} $. The reasons are as follows: If you put a product whose price is larger than the bench together, it will not contribute. If you put a product who ...

Posted on Mon, 11 Nov 2019 09:41:24 -0500 by designguy79

Extend the design pattern to solve practical problems: the logic of decoupling parameters changing and the formula relatively stable.

In the process of numerical simulation programming, there is a problem: some parameters or physical values are obtained through various operations by other parameters or variables. If the values of these parameters and variables are constants, we will not change them once they are initialized, so the problem becomes very simple, for example: co ...

Posted on Mon, 11 Nov 2019 04:23:48 -0500 by phpr0ck5

Luogu - P1018 product maximum problem solution

Original text: https://www.luogu.org/problemnew/solution/P1018?page=7   Title: P1018 [maximum product]   Preface: In theory, the positive solution of this problem is DP, but it is not difficult to use violence because of too much private data Overall thinking: A b array is used to mark whether each bit is divided (1-bit division, 0 is conne ...

Posted on Sun, 10 Nov 2019 10:42:31 -0500 by NoDoze

C -- using abstract method to realize simple factory design pattern

static void Main(string[] args){//Implementing a simple factory design pattern with abstract classes//Judge which brand of notebook to produce according to the user's inputConsole.WriteLine("please enter the brand of notebook you want to produce");string brand = Console.ReadLine();//Substitute the input value into the static method t ...

Posted on Sat, 09 Nov 2019 09:46:55 -0500 by Jewbilee

C + + -- initialization list

Q: is the definition of the following program class legal? #include <iostream> using namespace std; class Test { private: const int ci; public: Test() { ci=10; } int getCi() { return ci; } }; int main() { Test t; cout<<"t="<<t&lt ...

Posted on Thu, 07 Nov 2019 15:57:01 -0500 by Dark Phoenix

Solve partner pairing problems in a circular queue and discover your own problems

1. First of all, the use of this software vs2017 1. The usage of scanf() in VS Until I wrote this code, I didn't know that scanf would be warned in VS. The normal input function like scanf() function in VS is scanf_s(). You can't get an error unless you use this function. It has three parameters: data type, address and maximum storage. There ar ...

Posted on Thu, 07 Nov 2019 12:57:13 -0500 by nade93

[NOI2006] network charge

An interesting question for thieves. Think about converting the cost into something. Watch If we define the state of leaf node {A,0},{B,1}}, the state of non leaf node {Na > = Nb, 0}, {Na < Nb, 1}}, we can get the conclusion by combining the above figure The states of leaf nodes x, y (x < y) are the same The state of leaf node is th ...

Posted on Tue, 05 Nov 2019 14:33:47 -0500 by meandrew