Skip to content

Instantly share code, notes, and snippets.

View nmakeenkov's full-sized avatar

Nikolai Makeenkov nmakeenkov

View GitHub Profile
@nmakeenkov
nmakeenkov / main.py
Created October 10, 2019 09:02
4 numbers
def get_easy_res(n):
ans = 0
for a in range(1, n):
for b in range(1, n):
for c in range(1, n):
d = n - a - b - c
if d <= 0 or a == b or a == c or a == d or b == c or b == d or c == d:
continue
ans += 1
return ans
@nmakeenkov
nmakeenkov / main.py
Created October 10, 2019 09:01
3 numbers
def get_easy_res(n):
ans = 0
for a in range(1, n):
for b in range(1, n):
c = n - a - b
if c <= 0 or a == b or a == c or b == c:
continue
ans += 1
return ans
@nmakeenkov
nmakeenkov / main.kt
Created September 26, 2019 11:19
Avoid Prefix Palindromes
const val INF : Long = 1000 * 1000 * 1000 + 9
// n^k
fun pow(n: Long, k: Int): Long =
when
{
k == 0 -> 1L
(k % 2) == 0 ->
{
val x = pow(n, k / 2)