2 shunfurh shunfurh 于 2017.09.10 00:03 提问

Lingo

You are going to participate in the television show 'lingo'. You are very confident that you will make the finals of the show. This is not only because you are well prepared, but also because you managed to find a way to use your pda unnoticed during the contest, and you have already written a program to help you with the bonuswords.

In the finals of the show, you first solve as many lingo words as possible within the allowed time. This determines how many balls you may take afterwards. The more balls you may take, the higher your probability is of winning the finals. But it is not easy to see what this probability is. Write a program to help you with this.

For those who don't know the game of lingo, here follows a description of the last part of the finals, where you take the balls. You are given a square grid. Some squares in this grid are covered and the other squares contain numbers. A hopper in front of you contains numbered balls; there is exactly one ball for each numbered grid square. You take a ball at random (without replacement) from this hopper for each lingo word you solved in the first part of the finals. When you take a ball, the corresponding square in the grid becomes covered. You win the finals if an entire row, column or diagonal consist of only covered squares.
Input

On the first line an integer t (1 <= t <= 100): the number of test cases. Then for each test case:

One line with the integers n (1 <= n <= 8) and k (0 <= k), where n is the size of the lingo grid and k is the number of words you solved in the first part of the finals.

n lines, with on each line exactly n characters. Each character will be either '*' or '.', representing a covered square and a numbered square respectively.

There will be at least k numbered squares on the board, and there is no row, column or diagonal covered yet.

Output

For each test case:

One line with the percentage of getting lingo with either an absolute or a relative error of at most 10-6.

Sample Input

1
5 7
.*.*.
.**..
.*.*.
....
*
..*

Sample Output

82.703962704

1个回答

devmiao
devmiao   Ds   Rxr 2017.09.10 08:59
已采纳
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!
其他相关推荐
Lingo教育版免费申请流程
Lingo教育版申请流程(免费) 今天和队友在用Lingo求解一个非线性规划问题的时候,发现了网上目前流行比较广泛的Lingo11破解在运算速度上和运算结果上都存在误差,这里介绍一个Lingo的学生认证免费使用最新版的Lingo的流程。
Lingo基本使用方法
LP模型在Lingo中的一个典型输入方式: 1.以“MODEL:”开。 2.集合定义部分从(“SETS”到”ENDSETS”)定义集合及其属性。 3.给出优化目标和约束。 4.集合定义部分从(“DATA:”到”ENDDATA”)。 5.以”END”结束。目标函数的定义方法 @SUM(集合(下标):关于集合的属性的表达式)约束的定义方法 循环函数:@FOR(集合(下标):关于集合属性的约
lingo导入excel数据具体实现步骤
lingo导入excel数据的具体操作步骤
LINGO破解版
LINGO是用来求解线性和非线性优化问题的简易工具。LINGO内置了一种建立最优化模型的语言,可以简便地表达大规模问题,利用LINGO高效的求解器可快速求解并分析结果。
运用LINGO解决某些动态规划的问题
运用LINGO解决动态规划,求解数学模型的时候有用
LINGO-错误代码大全
LINGO出错时错误代码含义:       在LINGO程序求解时,系统首先会对程序进行编译.系统在编译或执行其他命令 时,会因程序中的错误或运行错误,弹出一个出错报告窗口,显示其错误代码,并简要指 出错误的原因.这些错误报告信息能够提示用户发现程序中的错误,以便能尽快修改.下 面我们给出出错信息的一个简要说明,仅供参考. LINGO错误编号及原因对照表 错误代
lingo错误代码对照大全
需要lingo11破解版,请留下邮箱。 0      LINGO模型生成器的内存已经用尽(可用“LINGO|Options"命令对General Solver 选项卡中的“Generator Memory Limit"选项进行内存大小的修改)      1      模型中的行数太多(对于有实际意义的模型,这个错误很少出现)      2      模型中的字符数太多(对于有实际意义的模型,
lingo使用
lingo详细教程lingo教程lingo读取写入excel数据读写excel示例代码MODEL: SETS: //HUIYUAN1指定M,T为一个1000维向量 HUIYUAN1/1..1000/:M,T; //DVDS1指定D为一个100维向量 DVDS1/1..100/:D; //指定C为1000*100的矩阵 LINKS1(HUIYUAN1,DVDS1):C; LINKS2(HUIYUAN1
简学lingo(一)——基础篇
1 模型的集部分
Linux/windows下java调用lingo
最近有一些朋友问我关于java程序调用lingo的问题,为了方便大家了解一些过程,下面就将java调用的详细过程重新写一下。在介绍java调用前首先介绍下,他们之间调用的原理。 原理:一个完整的java-lingo程序,必须包含三个要素,java程序-model文件-lingo软件,这三这个缺一不可,并且model文件与java程序是相互对应的也就是说如果你修改了其中任何一个文件其他的文件也