2020牛客多校第五场 I Hard Math Problem (画出结果的样子)

I Hard Math Problem

题目链接:https://ac.nowcoder.com/acm/contest/5670/I

题目描述
You are a player of the game Mine Craft. As a lawful good player, instead of droping TNT everywhere you want to build your village on a vast plain.

The game map could be recognized as a rectangle grid. In one grid, you can set up a gold miner, or an elixir collector, or a headquarter. You also can leave some grids green and vibrant.
However, one restriction for some good reasons is that a headquarter must be next to at least one gold miner and at least one elixir collector. ‘Next to’ means that their grids share one side – every grid is next to up, down, left, and right grids.

“Effeciecy!” A good old man said to you. You, the vast plain holder, want to be the most effecient player in the server. You want to maximize the number of headquarters in your village. Formally, If the village is a grid of size n × m n \times m n×m, we define the max number of headquarters can be built as f(n,m). For example, f(1,1) = 0 ,since there should be at least 3 grids for setting up a headquarter; f(1,6) = 2 and one possible solution is ( G ,   H ,   E ,   G ,   H ,   E ) . (G,\ H,\ E,\ G,\ H,\ E). (G, H, E, G, H, E).
To prove that you really understand the problem very well, print the efficiency on the infinite plain. Formally, you need to calculate lim ⁡ n → ∞ lim ⁡ m → ∞ f ( n , m ) n ⋅ m \lim_{n\to\infty} \lim_{m\to\infty} \frac{f(n,m)}{n\cdot m} limnlimmnmf(n,m).

输入描述:

No input.

输出描述:
A real number denoting the answer to the question. Round the answer to 6 decimal places. For example, if your answer is 0.123456789, print 0.123457.

题面:

在这里插入图片描述

思路

官方题解
在这里插入图片描述
解释一下:
因为求的是n和m都趋近无穷的情况下,所以边界情况可以不看。即边界可以看做就是符合的。那么题解给的情况就是
在这里插入图片描述
对于(i+j)%3=0的位置就放G和E,交叉着放,这样子就满足条件,每一个H 旁边有至少一个G和一个E,每个G和E都不相邻。(这里注意斜着的并不是相邻,上面第一排画出的上面应该还有,即先前所说的边界都是满足的意思)
可以看出每三个里有2个H,所以就可以看出是 2 3 2\over3 32

还有种看法就是转个方向看
在这里插入图片描述
在斜线上交错摆E和G,而斜线上测和下测都可以摆放H,这样占比最大且满足条件。所以还是可以看做三条斜线有两条都是H,趋近无穷就是 2 3 2\over3 32

代码

略,输出0.666667即可。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值