博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Educational Codeforces Round 60 D. Magic Gems
阅读量:4649 次
发布时间:2019-06-09

本文共 462 字,大约阅读时间需要 1 分钟。

易得递推式为f[i]=f[i-1]+f[i-M] 最终答案即为f[N]. 由于N很大,用矩阵快速幂求解。

code:

#include
using namespace std;typedef long long ll;const int MOD=1e9+7;ll n,m;struct mat{ ll a[105][105];};mat mat_mul(mat x,mat y){ mat res; memset(res.a,0,sizeof(res.a)); for(int i=0;i
>1; } c=res; ll ans=c.a[m-1][0]*2%MOD; for(int j=1;j
>n>>m; mat_pow(n); return 0;}

 

转载于:https://www.cnblogs.com/linruier/p/10596580.html

你可能感兴趣的文章