https://play.golang.org/p/YEK-6IWQ6Bw https://qiita.com/Nossa/items/a93024e653ff939115c6
GO 言語版です.
package main
import (
"fmt"
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 |
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) |
https://play.golang.org/p/YEK-6IWQ6Bw https://qiita.com/Nossa/items/a93024e653ff939115c6
GO 言語版です.
package main
import (
"fmt"
[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 |
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) |