摘要:
1.Fibonacci Number0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233,377, 610 …Formula:2.Lucas Number1, 3, 4, 7, 11, 18, 29, 47, 76, 123...Formula:3.Catalan Number1, 2, 5, 14, 42, 132, 429, 1430, 4862, 16796, 58786,208012…Formula:Application:1) 将 n + 2 边形沿弦切割成 n个三角形的不同切割数2) n + 1个数相乘, 给每两个元素加上括号的不同方法 阅读全文
摘要:
/*
还是暴力打表,然后规律
递推公式:
a[n]=4*a[n-1]+5(n为奇数)
a[n]=4*a[n-2]+5(n为偶数)
结果:
ans=2*4^n-5*(4^n-1)/3(n为奇数)
ans=2*4^n-4*(4^n-1)/3(n为偶数)
这里由于涉及到除法取余,所以还要把3的逆元求出来
*/
#include<stdio.h> #include<stdlib.h> #define mod 10007 //非递归方法求p^b
__int64 power(__int64 p,__int64 b) { __int64 sq=1; while(b... 阅读全文