快速幂
Error Man
我是菜逼
展开
-
快速幂模版(递归) 与 快速乘取模(模版)
快速幂 typedef long long ll; ll quick(ll a,ll b){ ll s=1; while(b > 0){ if( b&1 ) s *= a; //如果b不是2的倍数,即b二进制此位为1,s则*=a b /= 2; //b往下一位二进制数走 a *= a...原创 2018-07-25 13:46:50 · 380 阅读 · 0 评论 -
Codeforces 1182 E. Product Oriented Recurrence(矩阵快速幂 + 欧拉降幂 + 快速幂)
E. Product Oriented Recurrence Letfx=c2x−6⋅fx−1⋅fx−2⋅fx−3fx=c2x−6⋅fx−1⋅fx−2⋅fx−3forx≥4x≥4. You have given integersnn,f1f1,f2f2,f3f3, andcc. Findfnmod(109+7)fnmod(109+7). Input The only li...原创 2019-07-23 20:20:23 · 615 阅读 · 0 评论 -
FZU - 2303 Mind control(组合数学 + 期望)
Mind control There is a wonderful country where people like eating very much. Each person has exactly one direct follower while the follower's follower is also follower of this man (of course the mos...原创 2018-08-26 20:50:38 · 804 阅读 · 0 评论 -
HDU - 1395 2^x mod n = 1(欧拉定理)
2^x mod n = 1 Give a number n, find the minimum x(x>0) that satisfies 2^x mod n = 1. Input One positive integer on each line, the value of n. Output If the minimum x exists, print a line wit...原创 2019-07-17 11:37:08 · 273 阅读 · 0 评论 -
2019 牛客多校 第五场 B.generator 1(十进制矩阵快速幂)
generator 1 题目描述 You are given four positive integersx_0, x_1, a, bx0,x1,a,b. And you knowx_i = a \cdot x_{i-1} + b \cdot x_{i-2}xi=a⋅xi−1+b⋅xi−2for alli \ge 2i≥2. Given two positive integ...原创 2019-08-01 21:59:43 · 301 阅读 · 0 评论