Skip to content

Latest commit

 

History

12 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MAL

MAL

Mathematical Algorithms Library for OI.

luogu 团队 | 历史赛题 | English

有哪些优秀的百合同人作品?


面向信息学竞赛的数学算法库。
包含大量小常数数学算法模板,并支持压行后直接嵌入赛题交互库。

MAL 的核心目标是:
  数学向比赛题目的难度,不应过分受模板代码影响。

同时,MAL 不应影响不使用本库的选手正常完成题目。
接口使用方式见 MAL接口测试

原理

根据 luogu 的交互库说明
选手程序 main.cpp 会与题目提供的 interactive_lib.cpp 共同编译、链接。

本地可以近似使用:

g++ -std=c++14 -O2 interactive_lib.cpp main.cpp -o main

因此,MAL 可以将算法实现放入 interactive_lib.cpp,选手只需声明并调用对应接口。

一般交互题会由 interactive_lib.cpp 接管 main()
MAL 的使用方式不同:库代码只提供函数,不接管选手程序,因此不使用 MAL 的选手仍可正常作答。

仓库结构

MAL/
├── bundles/             # 发布:压行代码,与源码文件结构对应
│   ├── dgf/
│   │   ├── main.hpp           # 自动合并、压行版本
│   │   └── README.md          # 使用手册 / 算法说明
│   └── interactive_lib.cpp    # 洛谷交互库版本
├── include/             # 开发:模块化源码
│   ├── common/
│   │   ├── modint.hpp         # 静态模数类模板
│   │   └── ...                # 下文略去这些省略号
│   ├── poly/                  # 多项式全家桶
│   │   └── ntt.hpp
│   └── dgf/                   # dgf 全家桶
│       ├── convolution.hpp
│       ├── transform.hpp      # zeta / mobius / gcd / lcm
│       └── fps.hpp            # inv / ln / exp / pow ...
├── scripts/             # 构建:脚本合并工具
│   └── build.cpp              # 依赖解析 + 合并 + 压行
├── tests/               # 验证:正确性与性能测试
│   └── benchmark/
├── README.md
└── README_EN.md

规范

  • include/ 保存可读、可维护的正式源码。
  • 压行等操作统一由脚本完成,不直接污染源码。
  • 库代码默认兼容 C++14。
  • 尽量避免宏污染、全局状态和命名冲突。

About

Mathematical Algorithms Library for OI. A compact, low-constant-factor, highly optimized algorithm template library for OI. The interactive interfaces in our contest problems are built upon this repository.

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages