Non Built-in Data Structures And Algorithms in Python3
Unordered MultiSet
1 | class MultiSet: |
Fenwick Tree / Binary-indexed Tree
1 | class BIT: |
Non Built-in Data Structures And Algorithms in Python3
1 | class MultiSet: |
1 | class BIT: |
Universal Code Competition Template in Python3 (editing) [2022]
To calculate $ n^m % mod $:
DO NOT dividing an integer by another integer with respect to the modulus $mod$.
To calculate $ n/m%mod $ correctly ($ mod$ is a prime number thus $ φ(mod)=mod-1 $).
Use Eular function or modular multiplicative inversion.
1 | def kgcd(a, b): |
An enhanced InputReader
supporting keeping reading data until the end of input while the number of input cases is unknown:
一个加强版的输入器
,支持读到输入文件末尾的方式,用法类似java.util.Scanner
但效率显著提高: