Skip to content

Instantly share code, notes, and snippets.

View kunishi's full-sized avatar

Takeo Kunishima kunishi

View GitHub Profile
def binsearch(l, x):
f, t = 0, len(l) - 1
j = (f + t) // 2
while f <= t:
j = (f + t) // 2
if l[j] == x:
break
elif l[j] < x:
f = j + 1
else:
@kunishi
kunishi / abc255_c.py
Created June 11, 2022 14:42
AtCoder ABC255 Problem C
X, A, D, N = map(int, input().split())
first = min(A, A + D * (N - 1))
last = max(A, A + D * (N - 1))
if X <= first:
print(abs(first - X))
elif X >= last:
print(abs(X - last))
else:
@kunishi
kunishi / abc255_b.py
Created June 11, 2022 14:42
AtCoder ABC255 Problem B
N, K = map(int, input().split())
A = list(map(int, input().split()))
P = [[0, 0]]
for i in range(N):
P.append(list(map(int, input().split())))
distance = []
for i in range(1, N + 1):
d = []
for j in A:
@kunishi
kunishi / abc255-a.py
Created June 11, 2022 14:42
AtCoder ABC255 Problem A
R, C = map(int, input().split())
A = []
for i in range(2):
A.append(list(map(int, input().split())))
print(A[R - 1][C - 1])
i = 0; s = 0
while s < 1000:
i += 1
s += i ** 3
print(i, s)
print(i - 1)
i = 0; s2 = ''
while i < 5:
i += 1
s2 = s2 + 'Q' * i + '\n'
print(s2)
i = 0; s = 0
while s < 10:
i = i + 1
s = s + i
print(i, s)
print(i - 1)
@kunishi
kunishi / program.php
Created January 15, 2018 06:00
DEWS2005 program.php
<?php
session_start();
if((!isset($_SESSION["'sesLoginID'"]))||(!isset($_SESSION["'PHPSESSID'"]))){
session_destroy();
header("Location: ../index.html");
exit;
}
?>
<?xml version="1.0" encoding="euc-jp"?>
<?php
session_start();
if((!isset($_SESSION['sesLoginID']))||(!isset($_SESSION['PHPSESSID']))){
session_destroy();
header("Location: ../index.html");
exit;
}
?>
@kunishi
kunishi / dmg2iso.sh
Created December 21, 2017 04:40
convert dmg to iso on MacOS X
#!/bin/bash
IFS=$'\n'
for file in *.dmg; do
base=`basename $file .dmg`
hdiutil convert -format UDTO -o $base.cdr $file
mv $base.cdr $base.iso
done