[Solved] How to find the number of contiguous subsequences / subarrays whose product can be expressed as difference of squares of 2 random integers?

[ad_1] Any number can be represented as a difference of squares if it is odd, or a multiple of 4. The problem arises when a product has only a single 2 in the prime factorisation. So we can mark them. (i.e all the 2) Given this we can easily deduce that only what is not … Read more

[Solved] Matrix, how to solve? [closed]

[ad_1] import random n = int(input(‘Введите кол-во столбцов матрицы: ‘)) #columns m = int(input(‘Введите кол-во строк матрицы: ‘)) #rows matrix = [[random.randrange(0, 10) for y in range(n)] for x in range(m)] for i in range(m): for j in range(n): print(matrix[i][j], end = ” “) print() max_x = 0 for i in range(m): for j in … Read more

[Solved] Split an uneven number in even shares

[ad_1] Divide number by 6 and round to the nearest number. Your first 5 numbers were calculated in step 1. Last number = Initial number – (5 x number from step 1) 0 [ad_2] solved Split an uneven number in even shares

[Solved] PHP divide 2 values & echo 1 divided value [closed]

[ad_1] While this is a too basic question, here’s a possible solution. You only have to check the second variable, the first one is okay even if it’s 0: <?php $result = mysql_query(“SELECT * FROM high ORDER BY Runecraftlvl DESC LIMIT 20”); while($row = mysql_fetch_array($result)) { echo ($row[‘deaths’] != 0) ? $row[‘kills’] / $row[‘deaths’] : … Read more

[Solved] Ancient Japanese calendar exercise in C++

[ad_1] According to your list the Color rotates in a 10 years cycle and then has always 2 subsequent years with same color. Given that rule you can calculate an index in a field of year colors. #include <vector> #include <string> #include <iostream> using namespace std; int main() { const int base_year = 1984; vector<string> … Read more