## C + + singleton mode and thread safety

C + + singleton mode and thread safety
The simplest singleton mode can be
// single thread safe version
class Singleton {
public:
static Singleton* GetInstance(int x = 0) {
if (instance_ == NULL) {
instance_ = new Singleton(x);
}
return instance_;
}
void Print() { ...

Added by **sheen.andola** on *Sat, 05 Mar 2022 11:48:04 +0200*

## Explanation of Gauss elimination method

The essence of Gauss elimination is to simplify it into a stepped determinant. Firstly, the solutions of linear equations are as follows:
unsolvableThere are infinite solutionsUnique solution
The steps of Gaussian elimination are divided into the following four steps:
Enumerate each row to find the maximum absolute value of the current colu ...

Added by **slashpine** on *Tue, 08 Feb 2022 03:29:04 +0200*

## Segment tree -- interval maximum gcd problem

AcWing 246. Interval maximum common divisor Given A sequence A with length N and M instructions, each instruction may be one of the following two: C l r d means adding d to A[l],A[l+1],..., A[r]. Q l r, represents the maximum common divisor (GCD) of query A[l],A[l+1],..., A[r]. For each query, an integer is output to represent the answer.
Inp ...

Added by **brad_fears** on *Tue, 25 Jan 2022 04:50:31 +0200*

## Codeforces 1547f array stabilization (GCD version)

Title Link: Array Stabilization (GCD version)
General meaning
Given an array of length n, the subscripts are from 1 to n. where an and a1 are connected (form a ring)
Each round of operation yields a new array b: for all I ∈ [1, n], b[i] = gcd(a[i], a[i + 1]) (b[n] = gcd(a[n], a[1]) Finally, copy the new array b to the original array a
...

Added by **john-iom** on *Wed, 19 Jan 2022 11:52:20 +0200*

## Modular combination - Lucas/exLucas - LibreOJ #181 Binomial coefficient

Proof and code are separated, and you can jump according to your own needs.
Go to my Blog, maybe the reading effect is better
Lucas theorem
(
n
...

Added by **js_280** on *Fri, 14 Jan 2022 16:09:37 +0200*

## Number theory: application of maximum common divisor and minimum common multiple: Hankson's interesting problem

Summary:
1. If LCM (b, x) = = d, (the least common multiple of b, x = = d), you should know that B and X are divisors of d.
2. When b and x are divisors of d, the prime factors in b and x exist in the least common multiple of d.
3. Number of divisors: the upper bound of the number of divisors of n is sqrt(n), that is, there are at ...

Added by **kid_c** on *Mon, 10 Jan 2022 21:09:41 +0200*

## Special test mathematics 3

A. Solving equation
It is easy to do without considering the two restrictions. Use the board inserting method to divide \ (m \) balls into \ (n \) piles
It's \ (\ binom{m-1}{n-1} \)
The second limit is greater than or equal to, so you can allocate \ (a_i-1 \) to these numbers first
The first restriction is not easy to do directly, so consider i ...

Added by **froggie81** on *Fri, 07 Jan 2022 13:28:39 +0200*

## [record] math #1

10000 euro / Class Euro
Euclidean like algorithm
Board board.
[template] Euclidean algorithm
#include<bits/stdc++.h>
#define ll long long
#define N 22
#define P 998244353
ll t,p,q,r,l;
struct Po{
ll cntu,cntr,sumi,sums,sqrs,prod;
Po(){cntu = cntr = sumi = sums = sqrs = prod = 0;}
Po operator + (Po b) {
Po c;
c.cntu=(cntu+b.cntu ...

Added by **crimaniak** on *Thu, 30 Dec 2021 15:46:44 +0200*

## Extended Euclidean and bezu theorem

summary
Extended Euclid is used to solve the relevant equations
a
x
+
b
y
=
m
ax+by=m
The problem of ax+by=m
European ex ...

Added by **benwilhelm** on *Fri, 22 Oct 2021 10:50:16 +0300*