This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
using namespace std; | |
int calc(int temp, vector<int> &input, vector<int> &L, vector<vector<int>> &mem){ | |
if(L.size()==0){ | |
L.push_back(1); | |
mem.push_back(*new vector<int>(1,0)); | |
return 1; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
using namespace std; | |
int main(){ | |
int q; | |
cout << "Type the queries number: "; | |
cin >> q; | |
while(q--){ | |
string str; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
squares = [] | |
mx = 0 | |
class Square: | |
def __init__(self, height, val = 0): | |
if val == 0: | |
self.val = height | |
else: | |
self.val = val | |
self.height = height | |
def cont(self): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_rel(arr, i, i1 = -1): | |
if i!=0 or i1!=-1: | |
if i1==-1: | |
i1 = i-1 | |
if arr[i]>arr[i1]: | |
return +1 | |
elif arr[i]<=arr[i1]: | |
return -1 | |
else: | |
return 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
def task81(n): | |
d = {} | |
last_prime = 2 | |
if n == 2: | |
d = {2 : 1} | |
else: | |
while n > 1: | |
if n%last_prime == 0 and d.get(last_prime) == None: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function get_factorial(num){ | |
res = 1; | |
for (i = 1; i <= num; i++){ | |
res *= i; | |
} | |
return res; | |
} | |
function task84 (word){ | |
res = get_factorial(word.length); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function task85(k){ | |
console.log((-1+Math.sqrt(1+8*k))/2) | |
z = Math.ceil((-1+Math.sqrt(1+8*k))/2); | |
if (k%2==0){ | |
while (z%4!=3 && z%4!=0){ | |
z++; | |
} | |
}else{ | |
while (z%4!=1 && z%4!=2){ | |
z++; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function calculations(a, b){ | |
if (a >= b*3) { // When a is so big, that a/3 don't fit into b, so we get one row of squares with width b | |
return b; | |
/* | |
* ###. | |
*/ | |
}else if (a < b*3 && a > b*3/2) { // This is when a/3 is smaller than b, so it fit's into the b, but is bigger than b/2, so we still get one row with width a/3 | |
return a/3; | |
/* | |
* ### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function task87(N){ | |
let mem = []; | |
let sum = 0; | |
for (j = 0; j < N; j++ ){ | |
sum += 1; | |
if (j>1){ | |
sum+=mem[j-2]; | |
} | |
mem.push(sum); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def task90(M, N, A, B, cords): | |
massive = [["*" if any((cord[0]==x and cord[1]==y) | |
or (x in range(cord[0]-A+1, cord[0]+1) and y in range(cord[1]-B+1, cord[1]+1)) | |
or (x in range(M-A+1, M+1)) | |
or (y in range(N-B+1, N+1)) | |
for cord in cords) else "_" for x in range(M)] for y in range(N)] | |
# print(*massive, sep = "\n") # Uncomment this for visualization | |
res = 0 | |
for row in massive: | |
for elem in row: |
OlderNewer