Skip to content

Instantly share code, notes, and snippets.

@mizar
mizar / legal_policy.md
Last active June 17, 2022 17:48
将棋: 合法手として成立しうる駒の移動先と移動方向のパターンの数え上げ
@mizar
mizar / vrc-lt-converter_4k.ipynb
Last active September 20, 2022 16:07
vrc-lt-converter
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mizar
mizar / eratosthenes.rs
Last active December 10, 2022 15:51
高速なエラトステネスの篩 https://github.com/peria/primes/tree/master/eratosthenes の Rust版
// -*- coding:utf-8-unix -*-
//! エラトステネスの篩 & 生成した素数の試し割りによる素因数分解
//!
//! ## 素因数分解の実行例
//!
//! [`main`] を参照
//!
//! ## ベンチマーク実行例
//!
@mizar
mizar / png_out.py
Last active January 3, 2024 05:42 — forked from darka/png_out.py
Generating a PNG in Python
import base64, io, struct, zlib
from typing import BinaryIO, List, Tuple, Union
COLOR_TYPE_V = 0
COLOR_TYPE_VA = 4
COLOR_TYPE_RGB = 2
COLOR_TYPE_RGBA = 6
PixelV = Tuple[int]
PixelVA = Tuple[int, int]
use std::collections::HashMap;
fn greet_map(id: usize, name: String) -> HashMap<usize, String> {
let mut map = HashMap::new();
let message = format!("Hello, {}!", name);
map.insert(id, message);
map
}
fn main() {

For the calculation of the sum of integers $A, B$ in $N$-decimal, we divide the $(i-1):k$-digit part into $(i-1):j$-digit and $(j-1):k$-digit parts and consider whether the carry-over occurs for each. $(i \gt j \gt k)$

First, the integers $A, B$ are divided into $(i-1):j$ digits in $N$-decimal, and the values $A_{i-1:j}, B_{i-1:j}$ are added to determine whether carry-forward occurs for the digits above the interval, which are classified into three states as follows.

  • $A_{i-1:j}+B_{i-1:j} \lt N^{i-j}-1$ ; None
  • $A_{i-1:j}+B_{i-1:j} = N^{i-j}-1$ ; Propagate
  • $A_{i-1:j}+B_{i-1:j} \gt N^{i-j}-1$ ; Generate

Example for a decimal number:

@mizar
mizar / pmont.ipynb
Last active May 17, 2024 04:42
pmont.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mizar
mizar / stlang.ipynb
Last active September 27, 2024 18:16
StLang実行環境 Jupyter Notebook / Google Colab 向け https://yukicoder.me/problems/no/2906
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mizar
mizar / decimal_rounding_error.ipynb
Last active June 7, 2024 10:33
decimal_rounding_error.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mizar
mizar / stlang_env_standalone.py
Last active September 27, 2024 18:19
StLang実行環境 スタンドアロンパーサ版 https://yukicoder.me/problems/no/2906
"""StLang@Lark 実行環境サンプル standalone版"""
### TODO: ここからを本番の問題用の正しいコードに書き換える
PROGRAM = r"""
# サンプルプログラム: 二項係数 nCk の計算 (N > 62 の時は演算オーバーフローする可能性あり)
if N >= K # N < K の時の出力は 0 とする
$0 = 1
$1 = 1
$2 = N
while $1 <= K # for $1 in 1..=K