---
# System prepended metadata

title: Untitled

---

`非遞減字串`

```
import sys

in_txt = sys.stdin.read()

N = 1
M = 0

def smart(a,b):
  global N
  global M
  if a >=b:
    N += 1
    if N >= M:
      M = N
  else:
    if N >= M:
      M = N
    N = 1
  b = a
for in_txt_s in in_txt.splitlines():
  N = 1
  M = 0
  for i in range(1,len(in_txt_s)):
    smart(int(in_txt_s[i]), int(in_txt_s[i-1]))
  if N >= M:
    M = N
  print(M)

```

---
`身分證`
```
# A=10 B=11 C=12 D=13 E=14 F=15 G=16 H=17 I=34 J=18 K=19 L=20
# M=21 N=22 O=35 P=23 Q=24 R=25 S=26 T=27 U=28 V=29 W=32 X=30
# Y=31 Z=33

import sys

in_txt = sys.stdin.read()

check_num = 0

if in_txt[0] == 'A':
    check_num += 1 + 0 * 9
elif in_txt[0] == 'B':
    check_num += 1 + 1 * 9
elif in_txt[0] == 'C':
    check_num += 1 + 2 * 9
elif in_txt[0] == 'D':
    check_num += 1 + 3 * 9
elif in_txt[0] == 'E':
    check_num += 1 + 4 * 9
elif in_txt[0] == 'F':
    check_num += 1 + 5 * 9
elif in_txt[0] == 'G':
    check_num += 1 + 6 * 9
elif in_txt[0] == 'H':
    check_num += 1 + 7 * 9
elif in_txt[0] == 'I':
    check_num += 3 + 4 * 9
elif in_txt[0] == 'J':
    check_num += 1 + 8 * 9
elif in_txt[0] == 'K':
    check_num += 1 + 9 * 9
elif in_txt[0] == 'L':
    check_num += 2 + 0 * 9
elif in_txt[0] == 'M':
    check_num += 2 + 1 * 9
elif in_txt[0] == 'N':
    check_num += 2 + 2 * 9
elif in_txt[0] == 'O':
    check_num += 3 + 5 * 9
elif in_txt[0] == 'P':
    check_num += 2 + 3 * 9
elif in_txt[0] == 'Q':
    check_num += 2 + 4 * 9
elif in_txt[0] == 'R':
    check_num += 2 + 5 * 9
elif in_txt[0] == 'S':
    check_num += 2 + 6 * 9
elif in_txt[0] == 'T':
    check_num += 2 + 7 * 9
elif in_txt[0] == 'U':
    check_num += 2 + 8 * 9
elif in_txt[0] == 'V':
    check_num += 2 + 9 * 9
elif in_txt[0] == 'W':
    check_num += 3 + 2 * 9
elif in_txt[0] == 'X':
    check_num += 3 + 0 * 9
elif in_txt[0] == 'Y':
    check_num += 3 + 1 * 9
else:
    check_num += 3 + 3 * 9

check_num += int(in_txt[1]) * 8
check_num += int(in_txt[2]) * 7
check_num += int(in_txt[3]) * 6
check_num += int(in_txt[4]) * 5
check_num += int(in_txt[5]) * 4
check_num += int(in_txt[6]) * 3
check_num += int(in_txt[7]) * 2
check_num += int(in_txt[8])
check_num += int(in_txt[9])

if check_num % 10 == 0:
    print('合法')
else:
    print('不合法')
```
---
`TwoSum`
```
import sys

in_txt = sys.stdin.read()

in1,in2 = in_txt.split()
in3 = in1.split(',')
in2 = int(in2)

i = 0
left = 0
num_index = list(zip(in3, range(len(in3))))
right = len(num_index) - 1
while left < right:
  curr_sum = int(num_index[left][0]) + int(num_index[right][0])
  int (curr_sum)
  int(in2)
  if curr_sum == in2:
    print(num_index[left][1], num_index[right][1])
    break
  elif curr_sum < in2:
    left += 1
  else:
    right -= 1
```
---

提示:
完美數，有這些數列
https://en.wikipedia.org/wiki/List_of_Mersenne_primes_and_perfect_numbers

下面是正向解，一定timeout

```
import sys
txt = sys.stdin.read()
pf = [6,28,496,8128,333550336,8589869056]
# pf_sum = 0
# for i in range(1,int(txt)+1):
#     for l in range(1,int(txt)+1):
#         if int(txt) == i*l :
#             if i not in pf:
#                 if i != int(txt):
#                     pf.append(i)
#                     pf_sum += i
#             if l not in pf:
#                 if l != int(txt):
#                     pf.append(l)
#                     pf_sum += l
# print(pf)
# pf.remove(int(txt))
# print(pf)
# if pf_sum == int(txt):
#     print("True")
# else:
#     print("False")
if int(txt) in pf:
    print("True")
else:
    print("False")
```


---
信用卡

```
import sys
    
def twoAdd(ss):
  return(ss//10)+(ss%10)

str = sys.stdin.read()

q = str.splitlines()
for r in q:
  c = list(r)
  x = 0
  g = 0
  for b in c:
    if x % 2 == 0:
      s = twoAdd(int(b)*2)
    else:
      s = int(b)
    g += s
    x += 1
  if g %10 ==0:
    print('T')
  else:
    print('F')
```


---
兩樹相加

```
import sys
txt = sys.stdin.read()

def smart(a):
    target1 = a.split()
    target = target1[1]
    sum1 = target1[0].split(",")
    print(target,sum1)
    TR = []
    TR.clear()
    toto = 0
    for i in range(0,len(sum1)):
        print("這邊")
        for l in range(i+1,len(sum1)):
            toto = int(sum1[i])+int(sum1[l])
            if toto == int(target):
                print(toto)
                TR.append("T")
            else:
                TR.append("F")
    if "T" in TR:
        print("T") 
    else:
        print("F")


for i in txt.splitlines():
    
    smart(i)
```


---

兩數相加

```
import sys
    
def twoAdd(ss):
  return(ss//10)+(ss%10)

txt = sys.stdin.read()

c = txt.splitlines()
for e in c:
  g = 0
  h = e.split(' ')
  z = h[0].split(',')
  x = 0
  y = 0
  for i in z:
    for j in z:
      if(int(i)+int(j)) == int(h[1])and x != y:
        g = 1
        break
      y+=1
    x+=1
  if g == 1:
    print("T")
  else:
    print("F")
    
```
股票
import sys
import math
in_txt = sys.stdin.read().split()
qs = list(map(int, in_txt))
MA2_list = []
MA3_list = []
MA5_list = []

for i in range(len(qs)-1):
    MA2 = math.ceil((qs[i] + qs[i+1])/2)
    MA2_list.append(MA2)
 

for i in range(len(qs)-2):
    MA3 = math.ceil((qs[i] + qs[i+1]+qs[i+2])/3)
    MA3_list.append(MA3)

for i in range(len(qs)-4):
    MA5 = math.ceil((qs[i] + qs[i+1]+qs[i+2]+qs[i+3]+qs[i+4])/5)
    MA5_list.append(MA5)

print(*MA2_list, sep = ' ')
print(*MA3_list, sep = ' ')
print(*MA5_list, sep = ' ')


