233 Matrix

Problem Description
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 a0,1 = 233,a0,2 = 2333,a0,3 = 23333...) Besides, in 233 matrix, we got ai,j = ai-1,j +ai,j-1( i,j ≠ 0). Now you have known a1,0,a2,0,...,an,0, could you tell me an,m in the 233 matrix?

Input
There are multiple test cases. Please process till EOF.

For each case, the first line contains two postive integers n,m(n ≤ 10,m ≤ 109). The second line contains n integers, a1,0,a2,0,...,an,0(0 ≤ ai,0 < 231).

Output
For each case, output an,m mod 10000007.

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

Sample Output
234
2799
72937

2个回答

#include
using namespace std;

int a[11][110]={0};

int main(){
int n,m;

``````while (cin >> n>>m){
for (int i=1;i<=n;++i){
cin >> a[i][0];
}
for (int i=1;i<=m;++i){
if (a[0][i] != 0)continue;
if (i==1)a[0][i] = 233;
else {
a[0][i] = (a[0][i-1]*10+3)%10000007;
}
}//完成初始化

for (int i=1;i<=n;++i){
for (int j=1;j<=m;++j){
a[i][j] = (a[i-1][j]+a[i][j-1])%10000007;
}
}
cout << a[n][m]<<endl;
}
``````

}

``````
``````