bsgs ntt ex
扩展BSGS/exBSGS算法
上一篇博客提到,BSGS算法是用来解决形如:$a^{x}\equiv b\pmod{p}$ 的高次同余方程。其中 $a\perp p$。 那如果 $a$ 与 $b$ 不互质,阁下又该如何应对呢? exBSGS算法就是来解决形如:$a^{x}\equiv b\pmod{p}$ 的高次同余方程。其中 $ ......
BSGS算法
今天刚学了个算法:BSGS算法(Baby-Step Giant-Step),即大步小步算法。常用于求解离散对数问题。 该算法可以在 $O(\sqrt p)$ 的时间内求解形如:$a^{x}\equiv b\pmod{p}$ 的高次同余方程。 **问题:** [P3846 [TJOI2007] 可爱的 ......
任意模数多项式乘法MTT(可拆系数FFT、三模数NTT)笔记
# 任意模数多项式乘法 > 前言:\ > 在教练讲的时候脑子并不清醒,所以没听懂。后来自己看博客学会了,但目前只学了一种方法:可拆系数FFT。为了方便日后复习,决定先写下这个的笔记,关于三模数NTT下次再补。 > > 建议:准备好演算纸和笔,本篇含有大量推算部分。 > > 注:本篇文章是本蒟写的,d ......
快速数论变换NTT学习笔记
首先我们要明确一个方向,就是 $\text{FFT}$ 的原理是单位根的几个性质:
- 消去原理: $\omega_{tn}^{tk}=\omega_{n}^k$
- 对称原理:$\omega_{n}^{k}=-\omega_n^{k+\frac n 2}$
- $\omega_{n}^k=(\o... ......
AtCoder Beginner Contest 296 Ex Unite
[洛谷传送门](https://www.luogu.com.cn/problem/AT_abc296_h "洛谷传送门") [AtCoder 传送门](https://atcoder.jp/contests/abc296/tasks/abc296_h "AtCoder 传送门") 不错的 dp。 考 ......
AtCoder Beginner Contest 238 Ex Removing People
[洛谷传送门](https://www.luogu.com.cn/problem/AT_abc238_h "洛谷传送门") [AtCoder 传送门](https://atcoder.jp/contests/abc238/tasks/abc238_h "AtCoder 传送门") 考虑期望转计数,方 ......
AtCoder Beginner Contest 307 Ex Marquee
[洛谷传送门](https://www.luogu.com.cn/problem/AT_abc307_h "洛谷传送门") [AtCoder 传送门](https://atcoder.jp/contests/abc307/tasks/abc307_h "AtCoder 传送门") 一开始看错题了,看 ......
AtCoder Beginner Contest 245 Ex Product Modulo 2
[洛谷传送门](https://www.luogu.com.cn/problem/AT_abc245_h "洛谷传送门") [AtCoder 传送门](https://atcoder.jp/contests/abc245/tasks/abc245_h "AtCoder 传送门") 很好的题。 下文令 ......
AtCoder Beginner Contest 252 Ex K-th beautiful Necklace
[洛谷传送门](https://www.luogu.com.cn/problem/AT_abc252_h "洛谷传送门") [AtCoder 传送门](https://atcoder.jp/contests/abc252/tasks/abc252_h "AtCoder 传送门") ~~不知道为什么可 ......
AtCoder Beginner Contest 235 Ex Painting Weighted Graph
[洛谷传送门](https://www.luogu.com.cn/problem/AT_abc235_h "洛谷传送门") [AtCoder 传送门](https://atcoder.jp/contests/abc235/tasks/abc235_h "AtCoder 传送门") 为啥洛谷唯一一篇题 ......
[ABC282Ex] Min + Sum
[ABC282Ex] Min + Sum 一道分治题。比较新的地方在于,别的题都是按中点为M分治,而这道题是按最小值为M分治。记录b的前缀和sum。【L,R】最小值为M,则分为【L,M-1】,【M+1,R】。 #include<bits/stdc++.h> using namespace std; ......
AtCoder Beginner Contest 242 Ex Random Painting
[洛谷传送门](https://www.luogu.com.cn/problem/AT_abc242_h "洛谷传送门") [AtCoder 传送门](https://atcoder.jp/contests/abc242/tasks/abc242_h "AtCoder 传送门") 好久没复习过 mi ......
AtCoder Beginner Contest 253 Ex We Love Forest
[洛谷传送门](https://www.luogu.com.cn/problem/AT_abc253_h "洛谷传送门") [AtCoder 传送门](https://atcoder.jp/contests/abc253/tasks/abc253_h "AtCoder 传送门") 没做出来。 考虑求 ......
AtCoder Beginner Contest 298 Ex Sum of Min of Length
[洛谷传送门](https://www.luogu.com.cn/problem/AT_abc298_h "洛谷传送门") [AtCoder 传送门](https://atcoder.jp/contests/abc298/tasks/abc298_h "AtCoder 传送门") 挺无脑的。是不是因 ......
AtCoder Beginner Contest 290 Ex Bow Meow Optimization
[洛谷传送门](https://www.luogu.com.cn/problem/AT_abc290_h "洛谷传送门") [AtCoder 传送门](https://atcoder.jp/contests/abc290/tasks/abc290_h "AtCoder 传送门") 考虑观察答案形态。 ......
AtCoder Beginner Contest 281 Ex Alchemy
[洛谷传送门](https://www.luogu.com.cn/problem/AT_abc281_h "洛谷传送门") [AtCoder 传送门](https://atcoder.jp/contests/abc281/tasks/abc281_h "AtCoder 传送门") 考虑设 $f_i$ ......
(ex)BSGS/(扩展)大步小步算法 学习笔记
# (ex)BSGS/(扩展)大步小步算法 学习笔记 在即将暂时退役之际杀掉了[P4195](https://www.luogu.com.cn/problem/P4195)的毒瘤模板题,于是来写篇学习笔记。 谨此为我初中三年摆烂的OI生涯画上一个句号。(距离中考还有20天!) ## BSGS [li ......
ABC302Ex Ball Collector 题解
注意到当有那些 $(a_i,b_i)$ 是确定的时,答案就是将 $(a_i,b_i)$ 连边后每个连通块的 $\min(|V|,|E|)$ 之和。 那么这个东西用可撤销并查集维护即可。 ```cpp #include #include using namespace std; const int N ......
「学习笔记」模运算与 BSGS 算法
## 取模 > 取模符号:$x \bmod y$,表示 $x$ 除以 $y$ 得到的余数。 例如, $$ 5 \bmod 3 = 2\\ 7 \bmod 4 = 3\\ 3 \bmod 3 = 0\\ $$ 设 $x$ 为被除数,$y$ 为除数,$z$ 为余数,则 $x = k \cdot y + ......
【CUDA】GPU编程实现NTT算法
~~怎么有人选题迟了么得FFT啊。~~好久没更新博客了,来水一发! 参考资料: NTT:https://oi-wiki.org/math/poly/ntt/ CUDA实现FFT并行计算:https://blog.csdn.net/Liadrinz/article/details/106695275 ......
BSGS以及exBSGS
![](https://img2023.cnblogs.com/blog/3122215/202306/3122215-20230603110058010-1384770057.png =800x900) ![](https://img2023.cnblogs.com/blog/3122215/20 ......
[ABC270Ex] add 1
Problem StatementYou are given a tuple of $N$ non-negative integers $A=(A_1,A_2,\ldots,A_N)$ such that $A_1=0$ and $A_N>0$. Takahashi has $N$ counters ......
大步小步(BSGS)算法学习笔记
## 简介 大步小步(Baby Step Giant Step)算法,可以在 $O(\sqrt{p}\cdot f(p))$ 的时间复杂度内($f(p)$ 为一个大小为 $p$ 的映射结构(如 map、hash table)进行单次读取 / 随机访问 的时间复杂度)内解下列关于 $x$ 的方程(离散 ......
AtCoder Beginner Contest 247 Ex Rearranging Problem
[洛谷传送门](https://www.luogu.com.cn/problem/AT_abc247_h "洛谷传送门") [AtCoder 传送门](https://atcoder.jp/contests/abc247/tasks/abc247_h "AtCoder 传送门") 考虑我们如何判定一 ......
throw,throw ex 与 ExceptionDispatchInfo.Throw(ex)
有以下代码 using System.Diagnostics; using System.Runtime.ExceptionServices; using Microsoft.AspNetCore.Mvc; using static System.Net.Mime.MediaTypeNames; n ......
题解 AT_nikkei2019ex_e【コラッツ問題】
啥玩意,诈骗题还能这么诈骗。 $f(X)$ 就是角谷猜想(冰雹猜想)所需的步数。根据角谷猜想,定义函数 $g$: $$ g(X)= \begin{cases} \frac{X}{2},&2\mid X\\ 3X+1,&2\nmid X \end{cases} $$ 则显然有 $f(g(X))=f(X ......
AtCoder Beginner Contest 258 Ex Odd Steps
[洛谷传送门](https://www.luogu.com.cn/problem/AT_abc258_h "洛谷传送门") [AtCoder 传送门](https://atcoder.jp/contests/abc258/tasks/abc258_h "AtCoder 传送门") 不错的矩阵快速幂优 ......
AtCoder Beginner Contest 267 Ex Odd Sum
[洛谷传送门](https://www.luogu.com.cn/problem/AT_abc267_h "洛谷传送门") [AtCoder 传送门](https://atcoder.jp/contests/abc267/tasks/abc267_h "AtCoder 传送门") 直接暴力跑背包的复 ......
AtCoder Beginner Contest 302 Ex Ball Collector
[洛谷传送门](https://www.luogu.com.cn/problem/AT_abc302_h "洛谷传送门") [AtCoder 传送门](https://atcoder.jp/contests/abc302/tasks/abc302_h "AtCoder 传送门") 考虑如果只询问一次 ......