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

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 a … Read more

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

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 range(n): … Read more

[Solved] How necessary are mathematics in programming? [closed]

To graduate – You’ll need it for sure. An easy example are integrals, derivatives and stuff like that. A lot of subjects, at least in my university requires a basic understanding of maths. Another thing is what kind of a programmer you wanna be. Sure I guess you do not always have to use math’s … Read more

[Solved] Math for VB.net Progressbar 0 to 100%

Not sure if I get your question correctly… First, if what you want is to show a progressbar with some value that’s not 100… why not simply set the progres bar’s Maximum to your value (156761 in your example) and set Value to whatever progress it has? Now, if the progress bar for whatever reason … Read more

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

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++

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> colors … Read more