## Algorithms: count the number of pairs of elements whose product is a perfect square

Given two matrices whose elements are between $$(1.10 ^ 5)$$ and the size of the matrices is $$(1.10 ^ 5)$$How can we find the total number of pairs of elements of these matrices so that their product is a perfect square? The matrices can have the same elements.

For example:

Matrix 1: {1, 2, 4, 5}

Matrix 2: {4, 8, 16, 125}

Departure: 6

The pairs are (1, 4), (1, 16), (2, 8), (4, 4), (4, 16), (5, 125).

If the matrix size is $$10 ^ 5$$, a $$n ^ 2$$ The algorithm would be inefficient.

## Is it a good algorithm to find all pairs of strings between 2 sets so that all the words in the first string are contained in the second string?

I have 2 large sets of chains (they are actually product names). "Big" means a few million chains.

Example:

Series 1:

Some good product
Another product
Some name
Blah


Set 2:

Very long some product name with words blah
Another very long product name
Blah blah blah


Set 1 contains "good" names. Set 2 contains "dirty" names.

I want: for each element of Set 2 (below: element2) find the longest element of Set 1 (beyond: element1) so that all the words of element1 are contained in element2.

For the given example, the pairs will be the following:

Very long SOME product NAME with words blah => Some name
ANOTHER very long PRODUCT name              => Another product
BLAH blah blah                              => blah


Until now I couldn't think of anything better than the brute force algorithm:

1. Divide each string from Set 1 into words = we get a set of word lists, which is Set 3
2. Divide each string in Set 2 into words = we get a set of word lists, let it be Set 4
3. Choose a word list from Set 3 (below: list3), compare it to all the word lists in Set 4 until you find a list that is completely contained in list3.

However, it has a fairly high complexity and works quite slowly. My simple implementation takes about 1.8s to find 1 pair (set 1 has 3 mln elements, set 2 has 4 mln elements). If I implement the same task using MySQL full-text indexes (allows searching for strings that contain all the words given), then 1 search takes about 0.4s. So I wonder if there are some good approaches that could be applied here with small blood 🙂

My programming language is PHP7. The data is stored in MySQL DB.

## Count the number of triple vertices in the tree at a distance in pairs $D$

This question is about a problem in code forces:

Given a tree with $$N$$ nodes and a number $$D$$, calculate the number of triples $$(u, v, w)$$ such that $$mathit {dist} (u, v) = mathit {dist} (v, w) = mathit {dist} (u, w) = D$$.

Restriction: $$N, D le 10 ^ 5.$$

## bitcoind: how does the peer ban for onion pairs work?

If i start bitcoind with settings proxy=127.0.0.1:9050 to talk to the Tor Daemon SOCKS5 proxy, turn on listenonion=1 and establish onlynet=onionI understand that bitcoind It will coordinate with the demon Tor to find a random onion code / public identifier and start trading with other .onion pairs.

However, what prevents an onion node connected to Tor from behaving badly in a way that & # 39; normally & # 39; Would the IPV4 / V6 address be banned if it had been doing the same through that type of connection?

It seems to me that a malicious node could re-randomize the credentials in Tor to avoid any ban. Does this mean that Tor nodes are less robust than IPV4 / V6 and more susceptible to DDoS and other attacks? or has it been accounted for in any way?

An explanation would be useful. Thank you!

## 8 – Form api: how to configure group fields in pairs?

The code is taken from the "Excels API Form" and is complemented. There must be a couple of first and last name fields. An "Add more" button should add a new pair of "first and last name" fields below the existing one. This works (a little later using CSS to be on the same line). But they are grouped incorrectly, it turns out like this:

"name"
"name"
"name"
"surname"
"surname"
"surname"


but it is necessary to obtain (a little later using CSS to be on the same line)

"name"
"surname"
"name"
"surname"
"name"
"surname"


What am I doing wrong?

The code:

public function buildForm(array $form, FormStateInterface$form_state) {
$form('description') = ( '#type' => 'item', '#markup' =>$this->t('This example shows an add-more and a remove-last button.'),
);

// Gather the number of names in the form already.
$num_names =$form_state->get('num_names');
// We have to ensure that there is at least one name field.
if ($num_names === NULL) {$name_field = $form_state->set('num_names', 1);$num_names = 1;
}

$form('#tree') = TRUE;$form('names_fieldset') = (
'#type' => 'fieldset',
'#title' => $this->t('People coming to picnic'), '#prefix' => '', '#suffix' => '', ); for ($i = 0; $i <$num_names; $i++) {$form('names_fieldset')('name')($i) = ( '#type' => 'textfield', '#title' =>$this->t('Name'),
);
$form('names_fieldset')('surname')($i) = (
'#type' => 'textfield',
'#title' => $this->t('Surname'), ); }$form('names_fieldset')('actions') = (
'#type' => 'actions',
);
$form('names_fieldset')('actions')('add_name') = ( '#type' => 'submit', '#value' =>$this->t('Add one'),
'#ajax' => (
'wrapper' => 'names-fieldset-wrapper',
),
);
// If there is more than one name, add the remove button.
if ($num_names > 1) {$form('names_fieldset')('actions')('remove_name') = (
'#type' => 'submit',
'#value' => $this->t('Remove One'), '#submit' => ('::removeCallback'), '#ajax' => ( 'callback' => '::addmoreCallback', 'wrapper' => 'names-fieldset-wrapper', ), ); }$form('actions')('submit') = (
'#type' => 'submit',
'#value' => $this->t('Submit'), ); return$form;


Screenshot ## Contradiction test: just verifying a right neighbor in a sequence of different integers in pairs is enough to identify the first local maximum

I'm trying to find out if my test is valid, I think it makes intuitive sense, but I'm worried that something is missing. Any help would be highly appreciated!

A peak element is an element that is greater than its neighbors.

Given an input array nums, where nums(i) ≠ nums(i+1), find a peak element and return its index.

The array may contain multiple peaks, in that case return the index to any one of the peaks is fine.

You may imagine that nums(-1) = nums(n) = -∞.

Example 1:

Input: nums = (1,2,3,1)
Output: 2
Explanation: 3 is a peak element and your function should return the index number 2.

Example 2:

Input: nums = (1,2,1,3,5,6,4)
Output: 1 or 5
Explanation: Your function can return either index number 1 where the peak element is 2, or index number 5 where the peak element is 6.

public int findPeakElement(int() nums) {
for (int i = 0; i < nums.length-1; i++) {
if (nums(i) > nums(i + 1)) {
return i;
}
}
return nums.length - 1;
}


## Why don't you have to check the left neighbor in each item?

Assume towards a contradiction that we are iterating nums, still to discover a peak, and we find an element in the index i whose correct neighbor in the index i+1 It is strictly smaller. If the item in the index i were do not a peak, then the element in the index i-1 It would have to be strictly bigger. So we have that

nums(i-1) > nums(i) > nums(i+1)


This implies that nums(i+1) it is the last element in a sequence of strictly decreasing elements (which we have seen), whose beginning must be a peak (or the sequence begins at the index 0 or starts in the index k, 0 < k < i) This contradicts our assumption, therefore, the first element whose right neighbor is strictly smaller is a local peak.

## Raid: Dell PERC H710P 8 drives appear in 4 pairs with the same ID

I have traced Dell's documentation for the product, but for my life I cannot find out what I could be doing wrong. I have 8 4TB HGST SAS drives in a cabinet. Perc's BIOS will only allow me to set up a raid with half the capacity it should have. The raid configuration looks like this: !
As you can see, it seems to detect it as if they were two duplicate enclosures of four units per piece. I tried to assimilate it and create two virtual disks, but I can't. Does anyone here have experience with a PERC H710P and can possibly shed some light? I am without ideas. 🙁

## Algorithms – Temporal complexity of combinations of n pairs of parentheses

I have the following code snippet for combinations of n pairs of parentheses.

def parens(n):
if n <= 0:
return ('')
else:
combinations = ()
helper('', n, n, combinations)
return combinations

def helper(string, left, right, combinations):
if left <= 0 and right <= 0:
combinations.append(string)
else:
if left > 0:
helper(string + '(', left - 1, right, combinations)
if right > left and right > 0:
helper(string + ')', left, right - 1, combinations)


What is the reasonable estimate of the complexity of time?

My judgment:

1. (2n)! / N! N! since it is a complete permutation with the same element with more limitation: (upper limit)
2. Solve recurrence: T (n) = 2T (n-1) => O (2 ^ n)

## linear algebra – Test: No. of pairs in a string that begin and end with 1 is m * (m-1) / 2

Thank you for contributing a response to Mathematics Stack Exchange!

But avoid

• Make statements based on opinion; Support them with references or personal experience.

Use MathJax to format equations. Reference MathJax.

## Weekly negotiation forecasts in important pairs (June 2 to 6, 2014) – Discussions and help

These are the market prospects for the week:

EURUSD

Dominant bias: bearish

This market has been moving down slowly and late. Since the beginning of May 2014, the downward movement that began has reduced the market by more than 380 pips. With the bearish confirmation pattern on the chart, it is rational to expect the downward movement to continue, although the possibility of a temporary recovery along the way cannot be ruled out. The support line at 1.3500 is our goal for next week.

USDCHF

Dominant bias: bullish

This currency trading instrument has also been caught in a slow and late mode. After the "buy" signal was generated in early May 2014, the price rose more than 270 pips. Now, the possibility of the price going up cannot be ruled out, since the bias towards the north has been established. However, there could be some setbacks in the market along the way, but they should not bring the price below the support levels at 0.8950 and 0.8900. Any movement below support levels (especially the last one) would mean the end of the bias towards the north. Meanwhile, the price can walk towards our target at the resistance level of 0.9000. You can even break it up and move to another resistance level at 0.9050.

GBPUSD

Dominant bias: bearish

The Cable issued a spurious "buy" signal last week. Because the price could not move higher and break the accumulation territory in 1.6900 upwards, the Cable jumped in free fall and tested the accumulation territory in 1.6700. The "sale" signal in the market has been confirmed: the price could continue to go down, with the probability of reaching another accumulation territory at 1.6650.

USDJPY

Dominant bias: bearish

This is a difficult market, a market in which false outbreaks are no longer a curiosity. In addition, sustained trend movements are quite rare. Unless one is speculating or speculating on a day-to-day basis, one can think about leaving the market until a particular movement occurs. When it occurs, the price is more likely to fall.

EURJPY

Dominant bias: bearish

Since the beginning of May 2014, the cross has been reduced by about 400 pips. The bearish outlook remains valid and can continue until next week, reaching a target at 137.00. It is rational to sell the cross in demonstrations.

This forecast is concluded with the following quote:

“The keyword here is patience. If you are using the right strategies, you can be sure that (a) the bad execution will end, it's just a matter of time. " – Marcus de Maria