程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Blue Bridge Cup basic exercise special palindrome number -python- take out each digit in the number (Division) |csdn creation punch in

編輯:Python

Blue Bridge Cup Based on practice Special palindrome number -python- Take out each digit in the number ( division )|CSDN Creative punch in

  • Resource constraints
  • Problem description
  • Input format
  • Output format
  • The sample input
  • Sample output
  • Data size and engagement
  • Implementation code
  • matters needing attention
    • input Data type of
    • python Application of middle Division

Resource constraints

The time limit :1.0s Memory limit :512.0MB

Problem description

123321 It's a very special number , It's the same thing to read from the left as it is to read from the right .
Enter a positive integer n, Programming for all such five and six decimal numbers , The sum of your numbers equals n

Input format

The input line , Contains a positive integer n.

Output format

Output the integers satisfying the conditions in the order of small to large , Each integer takes up one line .

The sample input

52

Sample output

899998
989989
998899

Data size and engagement

1<=n<=54.

Implementation code

n = int(input())
for i in range(10000, 100000):
x = i % 10 + (i//10)% 10 + (i // 100)% 10 + (i//1000)% 10 +( i//10000)% 10
#print(x)
if x == n:
if i % 10==( i // 10000)% 10 and(i//10)% 10 == (i // 1000)% 10:
print(i)
for i in range(100001, 1000000):
x = i % 10 + (i //10 )% 10+ (i // 100)% 10 + (i // 1000 )% 10+( i // 10000 )% 10+(i//100000)% 10
# print(x)
if x == n:
if i % 10==(i//100000)% 10 and (i // 10 )% 10 == ( i // 10000 )% 10 and(i // 100)% 10 == (i // 1000 )% 10:
print(i)

matters needing attention

input Data type of

stay python3 in input Input is str If you want to compare the data in the type question, you should input the data z Convert to int type

python Application of middle Division

i =123456
print(i/10)# Conventional division 
print(i//10)# Only integer division is preserved 
print(i%10)# Take the remainder 
print(i/100)
print(i//100)
print(i%100)

Output

12345.6
12345
6
1234.56
1234
56

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved