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

建议使用的浏览器:

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

3552:Snatch!

Special Judge 特殊评判
题目描述

The company Supersafe produces a safe with a combination lock. The lock of this safe consists of N cylinders on a common axis. Each cylinder revolves on this axis independently of other cylinders. The are numbers from 1 to M in a circle on each cylinder. At any time, one of these numbers is visible in a special window on the door of the safe. Thus it is possible to enter numbers by rotating the cylinders. Accordingly, the code of the safe is a sequence of N numbers, each number belonging to the interval from 1 to M.

As a rule, such safes have a mechanism for opening them in the case the code is forgotten or lost. For this model, the mechanism has two components:

  • a key which is unique for each safe and kept by the owner. This key can be put in a keyhole only when the number 1 is entered on the first cylinder. After that, all the cylinders of the lock can be turned around only simultaneously (at the same time) by the same angle;
  • a universal technological code which is common for all safes. This code is known to a specialist of the company Supersafe, who should be invited to open the safe. It is known that the technological code starts with the number 1.

The process of opening the safe is as follows. The specialist enters the technological code (not allowing the owner to see the code, of course), puts in the key, and then turns all cylinders until – click – the safe unlocks. After that, the specialist takes out the key and mixes up the obtained code by entering random numbers on all the cylinders.

You want to open one of such safes without the owner’s knowledge. For this purpose, you have obtained a copy of the safe key and found out that:

  • after entering the technological code, putting in the key, and turning cylinders, the safe opens when the sum of numbers appearing in windows is maximal;
  • the correct technological code, selected from all codes starting with the number 1, has the least value of such sum.

It remains to determine the technological code.

输入解释

The input contains a single line with the values N and M. Both numbers are integers, belong to the interval from 2 to 20000 and are separated from each other by one or more spaces.

输出解释

The output also consists of one line. It contains the technological code. The numbers in this line should be separated by one or more spaces.

输入样例
2 10
输出样例
1 6

该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-3552

最后修改于 2020-10-29T07:04:22+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
1000 65536