Skip to content

Instantly share code, notes, and snippets.

View ZeronSix's full-sized avatar

Vyacheslav Zhdanovskiy ZeronSix

  • NVI Research, MIPT
  • Russia
View GitHub Profile
@ZeronSix
ZeronSix / 1521_militarytraining2.cpp
Last active October 31, 2015 09:58
1521. Военные учения 2
#include <iostream>
int find_mth_max(int tree[], int m, int n_max) {
int x = 1;
while (2 * x < n_max) {
if (tree[x * 2] >= m) {
x *= 2;
} else {
m -= tree[x * 2];
@ZeronSix
ZeronSix / 11_3.py
Last active October 25, 2015 15:55
11.3. Новогодний бал
with open("input.txt", "r") as fi:
n = int(fi.readline())
boys = list(map(int, fi.readline().split(" ")))
m = int(fi.readline())
girls = list(map(int, fi.readline().split(" ")))
boys.sort()
girls.sort()
j = m - 1
@ZeronSix
ZeronSix / 1008.py
Last active October 25, 2015 06:50
Школьная олимпида
with open("input.txt", "r") as fi:
k, n, p, s = map(int, fi.readline().split(" "))
i = 0
while True:
if (i + 1) * k > n or (i + 1) * k * p > s:
break
else:
i += 1
@ZeronSix
ZeronSix / 11_5.py
Last active November 5, 2015 10:58
11.5. Режем торт
import math
angles = []
n_top = 0
with open("tests/01") as fi:
n = int(fi.readline())
for _ in range(n):
x, y = [int(s) for s in fi.readline().split()]
angle = math.degrees(math.atan2(y, x))
@ZeronSix
ZeronSix / 11_3.py
Created October 22, 2015 11:07
11.3. Красивые числа
n = int(input())
split_table = {}
def get_split_sum(a, start_index, end):
l = end - start_index + 1
if l <= 2:
return 0
@ZeronSix
ZeronSix / 1494_monopool.py
Created October 20, 2015 14:38
1494. Монобильярд
n = int(input())
a = []
for _ in range(0, n):
a.append(int(input()))
stack = []
max_taken = 0
for i in range(0, n):
if a[i] > max_taken:
@ZeronSix
ZeronSix / 1654_encryption.py
Created October 20, 2015 11:02
1654. Шифровка
s = input()
ls = len(s)
stack = [s[0]]
i = 1
while i < ls:
if len(stack) > 0:
ch = stack.pop()
if ch != s[i]:
stack.append(ch)
@ZeronSix
ZeronSix / 1225_flags.py
Created October 16, 2015 15:21
1225. Флаги
#!/usr/bin/python3
def get_combination_count(i):
global arr
if arr[i - 1] == -1:
if i <= 2:
arr[i - 1] = 2
else:
arr[i - 1] = (get_combination_count(i - 2) +
@ZeronSix
ZeronSix / digits.cpp
Last active October 3, 2015 15:32
Задача о количестве цифр в записи чисел от 1 до n (C++)
#include <stdio.h>
long long* get_digit_count(long long n) {
long long* digit_count = new long long[10];
long long s = n;
int div = 1;
while (s > 0) {
s /= 10;
@ZeronSix
ZeronSix / digits.py
Created October 3, 2015 12:21
Задача о количестве цифр в записи чисел от 1 до n
def get_digit_count(n):
digit_count = [0] * 10
s = n
div = 1
while s > 0:
s //= 10
x = n - (div - 1)
full_period = x // (10 * div)
unfull = x % (10 * div)
unfull_periods = unfull // div