- 博客(4)
- 收藏
- 关注
原创 二分迭代求等比数列和
首先说明一下,为什么不直接套公式呢?因为(A/B)%C需要求B%C的模逆元,然后B,C还不一定是互素的,不互素,就没法把除法逆向为乘法了(至少我没听说过)。等比数列求和也可以用矩阵来写,这个主要看人。用二分来写比较简单,下面是代码int quik_sum(int a,int x){ int res = 1; while(x) { if(x&1) res = r
2015-08-16 00:33:44
442
原创 POJ 1170 暴搜+dp剪枝优先队列+状压
DescriptionIn a shop each kind of product has a price. For example, the price of a flower is 2 ICU (Informatics Currency Units) and the price of a vase is 5 ICU. In order to attract more cus
2015-08-15 23:46:18
296
原创 归并排序求逆序
LL inverse(int *arr, int len){ if (len==1)return 0; LL inverseLeft=inverse(arr, len/2); LL inverseRight=inverse(arr+len/2, len-len/2); if(inverseRight>=mod) inverseRight %= mod; i
2015-08-15 23:42:09
229
转载 矩阵快速幂模板
struct mat{ ll s[N][N]; mat(){ memset(s,0,sizeof s); } mat operator *(const mat c){ mat ans ; memset(ans.s,0, sizeof ans.s); for(int i=0;i<N;i++) for(int j=0;j<N;j++)
2015-08-15 23:37:34
316
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人