当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

3096:Life Game

题目描述
You are working at a production plant of biological weapons. You are a maintainer of a terrible virus weapon with very high reproductive power. The virus has a tendency to build up regular hexagonal colonies. So as a whole, the virus weapon forms a hexagonal grid, each hexagon being a colony of the virus. The grid itself is in the regular hexagonal form with N colonies on each edge.
The virus self-propagates at a constant speed. Self-propagation is performed simultaneously at all colonies.When it is done, for each colony, the same number of viruses are born at every neighboring colony. Note that,after the self-propagation, if the number of viruses in one colony is more than or equal to the limit density M,then the viruses in the colony start self-attacking, and the number reduces modulo M.
Your task is to calculate the total number of viruses after L periods, given the size N of the hexagonal grid andthe initial number of viruses in each of the colonies.
输入解释
The input consists of multiple test cases.
Each case begins with a line containing three integers N (1 <=N <= 6), M (2 <= M <= 10^9), and L (1 <=L <= 109).The following 2N &#8722; 1 lines are the description of the initial state. Each non-negative integer (smaller than M) indicates the initial number of viruses in the colony. The first line contains the number of viruses in the N colonies on the topmost row from left to right, and the second line contains those of N + 1 colonies in the next row, and so on.
The end of the input is indicated by a line “0 0 0”.
输出解释
For each test case, output the test case number followed by the total number of viruses in all colonies after L periods.
输入样例
3 3 1
1 0 0
0 0 0 0
0 0 0 0 0
0 0 0 0
0 0 1
3 3 2
1 0 0
0 0 0 0
0 0 0 0 0
0 0 0 0
0 0 1
0 0 0
输出样例
Case 1: 8
Case 2: 18
来自杭电HDUOJ的附加信息
Recommend lcy

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-3096

最后修改于 2020-10-25T22:59:58+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
10000/5000MS(Java/Others) 32768/32768K(Java/Others)