编程介的小学生 2017-09-13 09:13 采纳率: 20.5%
浏览 851
已采纳

Weather Forecast

As the master of weather forecast program appeared on television every day, Vivian is very interested in studying knowledge of weather forecast. She found that the forecast is in fact an approximate estimation of the weather in future. Further more, the observation of weather by human's eyes sometimes befools ourselves. For example, actually it is cloudy today, but the observer mistakes it into windy. It seems like a childish fault but it has really happened for more than once and makes this forecast job much more difficult. This discovery strongly enhances Vivian's interest so she takes a try to research on weather forecast now.

Let's describe the problem mathematically. There are N kinds of weathers {1, 2, ... , N} in all, such as "sunny", "rainy", "foggy", and so on. For a kind of weather i (1 <= i <= N), suppose the probability of mistaking it into weather j (1 <= j <= N) is A[i][j]. And for a certain day with weather i, the probability of the next day with weather j is B[i][j]. Given the probability of weather in the first day and the observation reports in M days, what are the weathers in these M days?

Input

The input consist of several test cases. In the first line of each case there is an integer N (0 < N <= 100), indicating the total number of different kinds of weathers. Then two matrices A and B follow (A before B), indicating the probabilities of mistaken observation and weather variation, which is referred above. Of course, all the floating numbers in the matrices are in the range (0, 1) and the sum of numbers in every row equals 1. The next line contains N floating numbers denoting the initial probability distribution of the weather in the first day (all are positive and the sum of them equal to 1), where the ith number means the probability of weather i in the first day. The last line contains M (0 < M <= 100) integers indicating the observations in these M days (including the first day), with each integer in the range [1, N].

The input ends with a case where N = 0. There is a blank line between adjacent cases.

Output

For each case, output M integers on a single line with each number in the range[1, N], representing the most possible weathers in these M days. Print a blank line after each case except the last one.

Sample Input

2
0.6 0.4
0.4 0.6
0.3 0.7
0.6 0.4
0.5 0.5
1 1 2 1

0

Sample Output

2 1 2 1

  • 写回答

2条回答 默认 最新

  • threenewbee 2017-09-29 15:56
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 lammps拉伸应力应变曲线分析
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试,帮帮忙吧
  • ¥15 #MATLAB仿真#车辆换道路径规划