随笔分类 -  板子 / 数学

摘要:debug:重载乘号的时候要把两个传进来的矩阵用起来 // Problem: P3390 【模板】矩阵快速幂 // Contest: Luogu // URL: https://www.luogu.com.cn/problem/P3390 // Memory Limit: 256 MB // Tim 阅读全文 »
posted @ 2024-03-21 22:02 potential-star 阅读(6) 评论(0) 推荐(0) 编辑
摘要:int n, m; int k; struct matrix{ int c[101][101]; matrix(){memset(c,0,sizeof c);} }; matrix operator*(matrix &a,matrix &b){ matrix t; for(int i=1;i<=n; 阅读全文 »
posted @ 2024-03-21 21:25 potential-star 阅读(11) 评论(0) 推荐(0) 编辑
摘要:三分法是二分法的变种,他最基本的用途是求单峰函数的极值点。 三分适用的情况:有唯一的最大值,满足最大值左侧严格单调递增,右侧严格单调递减(或左减右增)。强调严格单调,这样在确定最值是才能判断最值的位置,否则三分法不能缩小左右边界。 三分整数模板 整数的三分可能具有不确定性,可以通过改变while循环 阅读全文 »
posted @ 2024-02-01 22:07 potential-star 阅读(75) 评论(0) 推荐(0) 编辑
摘要:将O(n)优化成o(根号n) [CQOI2007] 余数求和 题目描述 给出正整数 nk,请计算 G(n,k)=i=1nkmodi 对于 100% 的数据,保证 1n,k109 void 阅读全文 »
posted @ 2024-01-29 23:09 potential-star 阅读(4) 评论(0) 推荐(0) 编辑
摘要:输出一个整数,表示a*b mod p的值。 数据范围 1≤a,b,p≤1018 ll qadd(ll a, ll b, ll p) { ll res = 0; while (b) { if (b & 1) res = (res + a) % p; a = (a + a) % p; b >>= 1; 阅读全文 »
posted @ 2023-12-16 20:23 potential-star 阅读(123) 评论(0) 推荐(0) 编辑
摘要:给定 n×n 的矩阵 A,求 A^k。 typedef long long LL; const int mod=1000000007; struct matrix{ LL c[101][101]; matrix(){memset(c, 0, sizeof c);} } A, res; LL n, k 阅读全文 »
posted @ 2023-12-10 02:51 potential-star 阅读(4) 评论(0) 推荐(0) 编辑
摘要:acwing的最基础模板 https://www.acwing.com/blog/content/406/ 知乎大佬给的各种数据范围模板大全:https://zhuanlan.zhihu.com/p/591377294 对于其中的一部分进行提炼形成自己的模板 1.使用场景:假设有n个数需要分解,每个 阅读全文 »
posted @ 2023-10-18 21:33 potential-star 阅读(118) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示