233 Matrix

In our daily life we often use 233 to express our feelings. Actually, we may say 2333, 23333, or 233333 ... in the same meaning. And here is the question: Suppose we have a matrix called 233 matrix. In the first line, it would be 233, 2333, 23333... (it means a 0,1 = 233,a 0,2 = 2333,a 0,3 = 23333...) Besides, in 233 matrix, we got ai,j = a i-1,j +a i,j-1( i,j ≠ 0). Now you have known a 1,0,a 2,0,...,a n,0, could you tell me a n,m in the 233 matrix?

InputThere are multiple test cases. Please process till EOF.

For each case, the first line contains two postive integers n,m(n ≤ 10,m ≤ 10 9). The second line contains n integers, a 1,0,a 2,0,...,a n,0(0 ≤ a i,0 < 2 31).OutputFor each case, output a n,m mod 10000007.Sample Input

1 1
1
2 2
0 0
3 7
23 47 16

Sample Output

234
2799
72937

Hint

#include<bits/stdc++.h>
#define MAX 15
#define MOD 10000007
using namespace std;
typedef long long ll; ll n,m;
struct mat{
ll a[MAX][MAX];
}; mat operator *(mat x,mat y)
{
mat ans;
memset(ans.a,,sizeof(ans.a));
for(int i=;i<=n+;i++){
for(int j=;j<=n+;j++){
for(int k=;k<=n+;k++){
ans.a[i][j]+=x.a[i][k]*y.a[k][j]%MOD;
ans.a[i][j]%=MOD;
}
}
}
return ans;
}
mat qMod(mat a,ll nn)
{
mat t;
memset(t.a,,sizeof(t.a));
for(int i=;i<=n+;i++){
t.a[i][]=;
for(int j=;j<=i;j++){
t.a[i][j]=;
}
t.a[i][n+]=;
}
t.a[n+][n+]=;
while(nn){
if(nn&) a=t*a;
nn>>=;
t=t*t;
}
return a;
}
int main()
{
int t,i,j;
while(~scanf("%I64d%I64d",&n,&m)){
mat a;
memset(a.a,,sizeof(a.a));
a.a[][]=;
for(i=;i<=n+;i++){
scanf("%I64d",&a.a[i][]);
}
a.a[n+][]=;
a=qMod(a,m);
printf("%I64d\n",a.a[n+][]);
}
return ;
}

最新文章

  1. 前端神器avalonJS入门(一)
  2. Node.js Base64 Encoding和Decoding
  3. Testing - 测试基础 - 方法
  4. Android 利用内容提供者添加联系人的操作
  5. Android TextWatcher监控EditText中的输入内容并限制其输入字符个数
  6. 自己封装的json工具类
  7. Intent Receiver
  8. Xcode快捷键 (本人总结常用的)
  9. 修改登录linux之后显示的默认文件夹目录
  10. 中文字符集编码Unicode ,gb2312 , cp936 ,GBK,GB18030
  11. The first to Python
  12. IPoint Interface接口
  13. Delphi获取其它进程窗口句柄的3种方法
  14. JavaNIO深入学习
  15. 我的PCB电路设计(一)
  16. SpringBoot+Mybatis+ Druid+PageHelper 实现多数据源并分页
  17. MySQL之sql文件的导入导出
  18. 如何关闭tornado.web的Application
  19. JAVA中的算法
  20. sass和scss的区别

热门文章

  1. ADAS
  2. visio_action
  3. Chrome性能分析工具Coverage使用方法
  4. mysql忘记root密码或报错:ERROR 1044 (42000): Access denied for user ”@’localhost’ to database ‘xx‘
  5. JAVA线程sleep和wait方法区别 代码
  6. 从动态库的def文件生成lib文件
  7. [BZOJ4557][JLOI2016]侦查守卫
  8. 加州小学grade1,学习计划
  9. access 驱动在win64位出现问题
  10. linkedin databus介绍——监听数据库变化,有新数据到来时通知其他消费者app,新数据存在内存里,多份快照