有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

爪哇皇后碰撞

我正在解决一个皇后碰撞问题,可以定位here

我只是需要一些帮助来理解说明。我能读懂文件,但我不明白的是我怎么知道女王的位置在哪里

我不明白这部分:

数据集的第一行包含空格分隔的正整数n g,其中n表示n x n板大小,g表示要描述的皇后的线性模式数,其中n<;30000和g<;250.接下来的g行各包含五个空白分隔整数,k x y s t,表示位置(x+i*s,y+i*t)处k个皇后的线性模式,对于i=0,1。。。,k-1。k的值为正。如果k是1,那么s和t的值是无关的,它们将被给出为0。所有女王职位都将在董事会上。所有线性模式中的皇后位置总数将不超过n,并且所有这些皇后位置将是不同的


共 (1) 个答案

  1. # 1 楼答案

    The first line of a dataset contains blank separated positive integers n g, where n indicates an n x n board size, and g is the number of linear patterns of queens to be described, where n < 30000, and g < 250. The next g lines each contain five blank separated integers, k x y s t, representing a linear pattern of k queens at locations (x + i*s, y +i*t), for i = 0, 1, ..., k-1. The value of k is positive. If k is 1, then the values of s and t are irrelevant, and they will be given as 0. All queen positions will be on the board. The total number of queen positions among all the linear patterns will be no more than n, and all these queen positions will be distinct.

    你读第一行的g,它会告诉你还有多少行。在每一行上,你读kxyst,并用它们来定位一些皇后k告诉你这个集合要放置多少个皇后,xy告诉你第一个皇后的位置,以及st告诉你皇后之间的距离。我不觉得这有什么难懂的