Skip to main content

to_bijective_digits

Function to_bijective_digits 

Source
pub fn to_bijective_digits(value: usize, base: usize) -> Vec<usize>
Expand description

正の value を bijective base-base(桁に 0 を使わない表記)の桁列へ変換します。

桁は上位から順に並びます。返される各桁は文字などへの添字として扱いやすいように 0..base で表され、数値としてはそれぞれ 1..=base に対応します。

§Panics

base が 2 未満、または value が 0 の場合は panic します。桁数を d とすると、 時間・追加領域はともに O(d) です。

§Examples

use atcoder::math::radix::to_bijective_digits;

assert_eq!(to_bijective_digits(1, 26), vec![0]);
assert_eq!(to_bijective_digits(26, 26), vec![25]);
assert_eq!(to_bijective_digits(27, 26), vec![0, 0]);