刚学python,还是免不了C++的代码风格。

Love Story

1
2
3
4
5
6
7
8
9
10
11
12
13
def solve():
str = input()
ans = 0
for i in range(10):
if(str[i] != std[i]):
ans +=1
print(ans)
###########
t = int(input())
std = "codeforces"
for i in range(t):
solve()

Blank Space

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#python
t = int(input())
for i in range(t):
n = int(input())
a = map(int,input().split())
temp = 0
ans = -1
for j in a:
if j == 0:
temp+=1
else:
temp = 0
ans = max(ans,temp)
print(ans)

A. Plus or Minus

1
2
3
4
5
6
7
8
9
10
11
def solve():
data = list(map(int,input().split()))
if (data[0] + data[1]) == data[2]:
print("+")
else:
print("-")

###########
t = int(input())
for i in range(t):
solve()

Grab the Candies

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
def solve():
n = int(input())
a = list(map(int,input().split()))
mh = 0
bika = 0
for i in a:
if(i % 2 == 0):
mh+=i
else:
bika +=i
if(mh > bika):
print("YES")
else:
print("NO")
###########
t = int(input())
for i in range(t):
solve()

Is It a Cat?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
def solve():
n = int(input())
str = input()
sta = 'm'
str = str.lower()
ss = str[0]
for i in range(1,n):
if(str[i] != str[i-1]):
ss += str[i]
if(ss == "meow"):
print("YES")
else:
print("NO")

###########
t = int(input())
for i in range(t):
solve()

A - YES or YES?

1
2
3
4
5
6
7
8
9
10
11
12
13
def solve():
str = input()
str = str.upper()
if(str == "YES"):
print("YES")
else:
print("NO")

###########
t = int(input())
for i in range(t):
solve()

B - ICPC Balloons

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
def solve():
ok = []
for i in range(26):
ok.append(0)
n = int(input())
str = input()
ans = 0
for ch in str:
if(ok[ord(ch) - ord('A')] == 0):
ans += 2
ok[ord(ch) - ord('A')] = 1
else:
ans +=1
print(ans)
###########
t = int(input())
for i in range(t):
solve()