内容中心

2026年比较好的搅拌器品牌厂家推荐-德州瑞驿减速机有限公司

德州瑞驿减速机有限公司,是国内较早从事刮泥机,螺旋升降机、丝杠升降机、QWL丝杠升降机、SWL丝杠升降机、JWM丝杠升降机、减速机、二次包络减速机、搅拌器、搅拌设备设计、制造和新型搅拌器研发的企业之一,已通过国际质量体系认证,公司拥有多名长期从事搅拌设备设计、研发、制造的工程技术专家,在多年的实践工作中,积累了丰富的设计制造经验;并且依靠计算机辅助设计、计算(公司自主开发的搅拌功率计算软件、搅拌轴强度计算软件等计算软件近十套),因此能为您提供最可靠、最经济的搅拌设备。同时,公司具有非常强的加工能力和完善的检测手段,从而能够为您提供异的产品。

To solve this problem, we need to determine the minimum number of deletions required to make a given number (as a string) divisible by 25. A number is divisible by 25 if its last two digits form one of the pairs: 00, 25, 50, or 75.

Approach

  1. Identify Valid Suffixes: The valid suffixes for divisibility by 25 are "00", "25", "50", and "75".
  2. Check Each Suffix: For each valid suffix, we need to find the rightmost occurrence of the second digit of the suffix, then find the rightmost occurrence of the first digit of the suffix before the second digit.
  3. Calculate Deletions: For each valid pair of positions (first digit, second digit), compute the number of deletions needed to keep these digits as the last two digits of the resulting number. The number of deletions is the original length of the string minus the length of the resulting number (which is the position of the first digit plus 2, since we keep all characters up to the first digit and the second digit).
  4. Find Minimum Deletions: The minimum number of deletions across all valid suffixes is the answer. If no valid suffix is found, return -1.

Solution Code

s = input().strip()
targets = [('0', '0'), ('2', '5'), ('5', '0'), ('7', '5')]
min_ops = float('inf')

for a, b in targets:
    idx_b = s.rfind(b)
    if idx_b == -1:
        continue
    idx_a = s[:idx_b].rfind(a)
    if idx_a == -1:
        continue
    ops = len(s) - (idx_a + 2)
    if ops < min_ops:
        min_ops = ops

print(min_ops if min_ops != float('inf') else -1)

Explanation

  1. Valid Suffix Check: For each suffix (like "25"), we first find the rightmost occurrence of the second digit ("5"). Then, we find the rightmost occurrence of the first digit ("2") before this position.
  2. Deletion Calculation: The number of deletions is calculated as the original length of the string minus the length of the resulting number (positions up to the first digit plus the second digit). This gives the minimum deletions needed for that suffix.
  3. Result: The minimum value from all valid suffix calculations is the answer, or -1 if no valid suffix exists.

This approach efficiently checks all possible valid suffixes and computes the minimum deletions required, ensuring optimal performance even for longer strings. The use of rfind helps in quickly finding the rightmost positions, making the solution both effective and efficient.

德州瑞驿减速机有限公司

德州瑞驿减速机有限公司



作者声明:本文包含人工智能生成内容。

在线客服

在线留言
您好,很高兴为您服务,可以留下您的电话或微信吗?