Skip to content

Instantly share code, notes, and snippets.

View c-yan's full-sized avatar

c-yan c-yan

View GitHub Profile
def slow_solve(N, K):
result = 0
for i in range(1, int(N) + 1):
s = str(i)
if len(s) - s.count('0') == K:
result += 1
return result
def fast_solve(N, K):
def f(N, K, f):
def validate(s):
g, p = 0, 0
for c in s:
if c == 'g':
g += 1
elif c == 'p':
p += 1
if p > g:
return False
return True
def ls(L):
L = int(L, 2)
result = 0
for a in range(L + 1):
for b in range(L + 1):
if a + b > L:
continue
if a + b != a ^ b:
continue
result += 1
L = int(input(), 2)
result = 0
for a in range(L + 1):
for b in range(L + 1):
if a + b > L:
continue
if a + b != a ^ b:
continue
result += 1
@c-yan
c-yan / numpy.py
Last active December 12, 2019 08:41
A = [0] * N
A = np.zeros(N, dtype = np.int64)
A = [1] * N
A = np.ones(N, dtype = np.int64)
s = list(input())
i = 0
result = 0
while i < len(s) - 2:
if s[i] != 'A':
i += 1
continue
if s[i + 1] == 'B' and s[i + 2] == 'C':
result += 1
parent = [-1] * n
def find(parent, i):
if parent[i] < 0:
return i
parent[i] = find(parent, parent[i])
return parent[i]
def unite(parent, i, j):
i = find(parent, i)
@c-yan
c-yan / gist:451a59fed7448cdec79eb0ef33fcc9a7
Last active August 7, 2018 11:15
『ポリモーフィズムを活用するとなぜ if や switch が消えるのか?』プログラマー2年生が説明してみる。 へのコメント
@c-yan
c-yan / create-circle-cut.ps1
Created June 16, 2018 09:12
script for creating circle cut of M3
[IO.Directory]::SetCurrentDirectory((Get-Location).Path)
Add-Type -AssemblyName System.Drawing
$b = new-object System.Drawing.Bitmap 650, 1000
$g = [System.Drawing.Graphics]::FromImage($b)
$g.Clear([System.Drawing.Color]::White)
$f = new-object System.Drawing.Font "Noto Sans CJK JP Regular", 45
$g.TextRenderingHint = [System.Drawing.Text.TextRenderingHint]::AntiAlias
$g.DrawString("みゃねっと", $f, [System.Drawing.Brushes]::Black, (new-object System.Drawing.PointF 50, (400 - 20)))
$f.Dispose()
$f = new-object System.Drawing.Font "Noto Sans CJK JP Regular", 34
@c-yan
c-yan / zlib_mingw.txt
Created May 29, 2018 13:59
Compile zlib with mingw
Microsoft Windows [Version 10.0.17134.48]
(c) 2018 Microsoft Corporation. All rights reserved.
C:\zlib-1.2.11>SET PATH=C:\MinGW\bin;%PATH%
C:\zlib-1.2.11>gcc -v
Reading specs from C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/specs
Configured with: ../gcc-3.4.5-20060117-3/configure --with-gcc --with-gnu-ld --with-gnu-as --host=mingw32 --target=mingw32 --prefix=/mingw --enable-threads --disable-nls --enable-languages=c,c++,f77,ada,objc,java --disable-win32-registry --disable-shared --enable-sjlj-exceptions --enable-libgcj --disable-java-awt --without-x --enable-java-gc=boehm --disable-libgcj-debug --enable-interpreter --enable-hash-synchronization --enable-libstdcxx-debug
Thread model: win32
gcc version 3.4.5 (mingw-vista special r3)