编程介的小学生 2017-08-19 02:16 采纳率: 20.5%
浏览 789
已采纳

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条回答 默认 最新

  • 肥宅_小清新 2017-08-19 08:03
    关注

    #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;
    }    
    

    }

    
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?