English 中文(简体)
删除最低点数
原标题:Remove the minimum number of blades

最近,我在http://acm.timus.ru/problem.aspx?space=1&num=1765”上接过这个问题。 Timus在线法官。 不愿点击该链接的人。 问题如下:

Experienced participants of the Ural Championship come to Yekaterinburg in advance to get accustomed to the severe weather conditions, walk around the city, and, of course, visit the “Limpopo” Water Park. Not many people know that there is Plant No. 404 near the water park, and this plant is called “Error 404” by the locals. The plant is not easy to find indeed, and it is still more difficult to learn what is happening there. Fortunately, one can watch the plant from a nearby pedestrian bridge. Because of the seeming stillness and desolation of the plant, one may think that it is out of operation, but this is not so. The main work area of the plant is the repair of aviation engines. Some time ago the plant received an order to repair a broken gas turbine engine. It turned out that some blades were torn off, which resulted in an excess load on the engine shaft. Experts at the plant have decided that the engine could be repaired quickly by removing some of the intact blades so that the center of masses of the remaining blades would be on the rotation axis once again. To keep the engine power as large as possible, a minimum number of blades should be removed. At least one blade must be left, otherwise the engine would not work at all. The experts assert that when all the blades were intact their endpoints formed a regular n-gon. Tell them which blades should be removed.

> Input The first line contains the initial number of blades in the
> turbine n and the number of torn blades k (3 ≤ n ≤ 20000; 1 ≤ k ≤ n −
> 1). The integer n has at most two distinct prime divisors. The next
> line contains k integers, which are the numbers of the torn blades in
> ascending order. The blades are numbered from 1 to n clockwise. 
Output
> In the first line output the minimum number of blades that should be
> removed. In the second line output the numbers of these blades in any
> order separated with a space. If several answers are possible, output
> any of them. If it is impossible to repair the engine by removing some
> of the blades, output “−1”. 
> 

我正在制造这一问题。 我的初步想法是,由于需要找回大众中心,需要四舍五入到数目相同的非中间点。

So if we represent a broken blade as 0 and an unbroken blade as 1, a particular configuration can be represented as: 011

I am not sure if I am on the right track and some feedback will be awesome in trying to understand this problem.

增 编

问题回答

空白处最初形成一个固定的<代码>n-gon。 视之为复杂数目。 如果不丧失一般性,rad为1,轴线就位于斜面上,斜线为n

空白之处为<代码>n-th origin of Unity, the tip of bladecode>k

z_k = e^(2pi i * k/n)

删除“条码”后,......、kr在轮式轴线上,如果并且只在这样的情况下才如此。

z_k1 + z_k2 + ... + z_kr = 0

Now let 1 < d < n be a divisor of n. The blades k1 + m*d, 0 <= m < n/d form the vertices of a regular n/d-gon. Thus removing them all leaves the center of mass on the rotation axis.

该战略将试图通过一套互不关联的定期<代码>d_i-gons,其中d_in的分母。 因此,在清单中发现,其指数因<代码><>n/code>的分数而异。

我的初步想法是,由于需要找回大众中心,需要四舍五入到数目相同的非中间点。

页: 1 推进器必须轮流测量。 如果一刀切的推进剂被打碎,就没有任何东西可以 recent。

要点是:

  1. The experts assert that when all the blades were intact their endpoints formed a regular n-gon.
  2. The integer n has at most two distinct prime divisors.

开始的是符合这两种特性的简单东西,例如 de。 Ask yourself: How do polygons and symmetry associated? 那么,10位分母如何与多角和高金属有关? 为了简化工作,你能否用粗体字而不是两维点来代表这些多角点? Hint: 模块算术对解决方案的影响。

lade形构造(未固定和固定)应有所帮助。 例如:

        2                     2                     2                   2           
    3       1                     1                                                 
  4           0         4           0         4           0       4           0     

  5           9         5                                 9       5           9     
    6       8             6       8             6       8                   8       
        7                     7                     7                   7           
   whole 10-gon        2 broken blades       3 broken blades     3 broken blades

对2个破碎的空白点和头3个破碎的空白点有两种可能的解决办法,但只有一种是最佳的。 第二名3名经纪人有一个解决办法。 看一角。

这个问题在数学上确实非常复杂,但可以通过对如何平衡工作的良好理解加以简化。

  • If the number of blades "n" is a prime number, there is no solution other than removing every blade. One can t rebalance even one missing blade when n is a prime. If there is no solution for one blade, there won t be a solution for multiple missing.
  • It the number of blades "n" is not a prime, by definition (and according to the rule of this problem) it is the produce of two primes "p1" and "p2", Example: for 21 blades, p1=3, p2=7.

If one blade "k1" is missing, balance will be obtained when a total of "N/p2 (example=3) blades equally spaced have been removed (visualize the Mercedes Benz sign). If two blades "k1" and "k2" are missing, balance will be obtained by doing exactly for "k2" as the preceding case, EXCEPT if k1 and k2 are spaced following the "p1" or "p2" symmetry

Examples with 12 and 20 blade make things difficult to understand, because they are multiple of 4, which means two symmetries of an order 2. I prefer examples with 21 blades, which don t have this problem.

  1. 21 Blades, one missing blade k1 = 1 -> Balance is obtained by removing blade 8 and 15 (Symmetry p1 is order 3)
  2. 21 Blades, two missing blades k1=1, k2=2 -> Balance is obtained by removing blade 8 and 15 for k1, and 8 and 16 for k2
  3. 21 Blades, two missing blades k1=1, k2=8 -> since k2-k1=7, you just need to remove blade 15 to complete the balance
  4. 21 Blades, two missing blades k1=1, k2=7->since k2-k1=6 = 2*3, you can remark that the blades are on the symmetry of order 7, therefore you could complete the pattern by removing the blades 4,10,13,16,19 to get perfect balance. But interestingly, you can also treat it as the example #2, and use two times the symmetry of order 3; so there is also a solution by removing blade 8 and 15 to balance k1, and 14 and 21 to balance k2.

Therefore to solve your problem, your algorithm should do these things: - If n is a prime, simply output "-1" - no solution - Starting wit the first missing blade, scan for groups of missing blade spaced by "n/p1 (= 7)" and "n/p2(=3)" . Count how many groups of each symmetry group have, and how many blades you need to replace.

  • In the example, your first order solution is simply:
    The number of blades to remove will be (number of groups of symmetry p1) *7 + (Number of groups of symmetry p2 )*3 - number of blades missing. You ll have to treat the exceptions like the one shown in example 4 where it is better to treat blades individually, but you get the picture.




相关问题
How to add/merge several Big O s into one

If I have an algorithm which is comprised of (let s say) three sub-algorithms, all with different O() characteristics, e.g.: algorithm A: O(n) algorithm B: O(log(n)) algorithm C: O(n log(n)) How do ...

Grokking Timsort

There s a (relatively) new sort on the block called Timsort. It s been used as Python s list.sort, and is now going to be the new Array.sort in Java 7. There s some documentation and a tiny Wikipedia ...

Manually implementing high performance algorithms in .NET

As a learning experience I recently tried implementing Quicksort with 3 way partitioning in C#. Apart from needing to add an extra range check on the left/right variables before the recursive call, ...

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

Enumerating All Minimal Directed Cycles Of A Directed Graph

I have a directed graph and my problem is to enumerate all the minimal (cycles that cannot be constructed as the union of other cycles) directed cycles of this graph. This is different from what the ...

Quick padding of a string in Delphi

I was trying to speed up a certain routine in an application, and my profiler, AQTime, identified one method in particular as a bottleneck. The method has been with us for years, and is part of a "...

热门标签