![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
算法
BeToBe_
?????
展开
-
快速乘取模运算
**基于快速幂(见上篇**ll mul_mod(ll a, ll n){ ll ans = 0; while (n) { if (n & 1) ans = (ans + a) % mod; a = (a + a) % mod; n /= 2; } return ans;}原创 2017-07-10 20:45:24 · 917 阅读 · 0 评论 -
快速幂取模
快速幂取模(快速的求一个幂式的模(余),通常是大数取余的运算 1.模运算:(a+b)%m=(a%m+b%m)%m(a-b)%m=(a%m-b%m)%m(a*b)%m=(a%m*b%m)%m2.位运算: & 按位与 >> 右移,正数高位补0,负数由计算机决定按位与运算按位与运算原创 2017-07-10 20:51:10 · 514 阅读 · 0 评论 -
求某个范围内的所有素数(内含埃氏筛法
Description 求小于n的所有素数,按照每行10个显示出来。 Input 输入整数n(nOutput 每行10个依次输出n以内的所有素数。如果一行有10个素数,每个素数后面都有一个空格,包括每行最后一个素数。 Sample Input 100 Sample Output 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47原创 2017-07-10 22:51:15 · 1327 阅读 · 0 评论 -
Fence Repair(哈夫曼算法+优先队列
Fence Repair Time Limit: 2000 ms / Memory Limit: 65536 kb DescriptionFarmer John wants to repair a small length of the fence around the pasture. He measures the fence and finds that he needs原创 2017-07-11 23:28:34 · 430 阅读 · 0 评论