内容中心

2026年靠谱的吊扇电机全自动装配线组装高口碑品牌推荐-佛山市阜创自动化设备有限责任公司

佛山市阜创自动化设备有限责任公司是一家专业从事自动化设备生产,机器人应用,非标定制设备研发等各个领域、生产和销售于一体的企业。公司自成立以来,一直以“进取 求实 严谨 团结”的理念不断开拓一路创造,推动制造自动化设备的进展研发回报社会。我们将坚持生产**产品,提供优质高效的服务,并不断创新,以顺应市场的发展需求,与您携手,共赢未来!主要产品:   1、电机自动装配组装检测线体,电机自动锁螺丝,转盘螺丝机直线螺丝机,吸附式螺丝机,手持式螺丝机,小型桌面转盘式螺丝机等;   2、风扇电机转子外圆粗车精车加工外圆拟光涂色,机壳自动注油铆压机,转子自动压轴机,弹片风叶轴承卡簧定子浸漆等;   3、罩及电机转子外圆加工,粗车精车加工,拍平搅孔,外圆抛光涂色,支架注油铆压机,转子自动压轴,主副定子拍平,48#58#61#主副定子自动铆压机,骨架自动插端子,自动穿轴套等;   4、脚轮自动组装装配,二三极插头自动组装,视觉检测设备,激光切割设备,激光打码机,钻孔攻牙设备,伺服自动压力机,自动旋转贴标签机器、自动上料机,变压器自动扭线机,阀门自动组装弹簧插销机;   5、吊扇电机全自动装配线,前后盖自

To solve this problem, we need to count the number of non-empty palindromic substrings in a given string. A palindromic substring reads the same forwards and backwards.

Approach

The key insight to efficiently count palindromic substrings is to use the expand around centers technique. This approach leverages the fact that every palindrome has a center:

  1. Odd-length palindromes: The center is a single character.
  2. Even-length palindromes: The center is between two characters.

For each center, we expand outwards as long as the characters on both sides are equal, counting valid palindromic substrings as we go. This method ensures we cover all possible palindromic substrings with a time complexity of O(n²), which is efficient for typical input sizes.

Solution Code

def count_palindromic_substrings(s):
    n = len(s)
    count = 0

    # Check for odd-length palindromes
    for i in range(n):
        left, right = i, i
        while left >= 0 and right < n and s[left] == s[right]:
            count += 1
            left -= 1
            right += 1

    # Check for even-length palindromes
    for i in range(n - 1):
        left, right = i, i + 1
        while left >= 0 and right < n and s[left] == s[right]:
            count += 1
            left -= 1
            right += 1

    return count

# Read input and output the result
s = input().strip()
print(count_palindromic_substrings(s))

Explanation

  1. Odd-length palindromes: For each character in the string, we start with the character as the center and expand outwards. For each valid expansion (both sides are equal), we increment the count.
  2. Even-length palindromes: For each pair of consecutive characters, we start with the pair as the center and expand outwards, counting valid palindromes.

This approach efficiently covers all possible palindromic substrings, ensuring we do not miss any. The overall time complexity is O(n²) because each center expansion can take up to O(n) steps, and there are O(n) centers (n for odd, n-1 for even).

Example Walkthrough

Let's take the string "aaa" to see how the code works:

  • Odd-length:
    • Center at index 0: count +=1 (substring "a").
    • Center at index1: count +=1 ("a"), then expand to index0 and 2 → count +=1 ("aaa").
    • Center at index2: count +=1 ("a").
    • Total for odd: 4.
  • Even-length:
    • Center between index0 and 1: count +=1 ("aa").
    • Center between index1 and2: count +=1 ("aa").
    • Total for even:2.
  • Total:4+2=6, which is correct.

This method works for all cases and is optimal for the problem constraints.

佛山市阜创自动化设备有限责任公司

佛山市阜创自动化设备有限责任公司



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

在线客服

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