编程介的小学生 2020-01-17 21:42 采纳率: 20.5%
浏览 73

Jumping Robot 跳跃的罗伯特

Problem Description
Ali invents a jumping robot. This robot is controlled by a program {Di}, which is a finite sequence of non-negative “jumping distances”. The program can’t be changed once the robot is made.
There are L boxes in a line. Each time the robot is placed in one of the boxes, facing left or right, and then it is turned on. It first jumps over D1 boxes, then jumps over D2 boxes ...
Ali writes a capital letter in each box. The robot prints out all the letter it touches, including the initial one. Now he wants to design a program with a length of p, so that for every kind of letters in the boxes, if you carefully choose the initial position and direction of the robot, it can print out a sequence of that letter of length p.
What’s the maximum possible p for the given letters in boxes?

Input
The input consists several testcases.
The first line contains 2 integers n (4 <= n <= 8) and L (4 <= L <= 100), represents the number of different capital letters and the number of boxes.
The second line contains a string whose length is exactly L, represents the letters in each box. The string only contains the first n capital letters, and each letter appears at least once in the string.

Output
Print an integer, the maximum length of the jumping program.

Sample Input
4 15
DABCDDCCBAACBBA

Sample Output
3

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 安卓adb backup备份应用数据失败
    • ¥15 eclipse运行项目时遇到的问题
    • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
    • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
    • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
    • ¥50 成都蓉城足球俱乐部小程序抢票
    • ¥15 yolov7训练自己的数据集
    • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
    • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
    • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)