This time the problem was simple, so I could solve A ~ C, but I should have solved D.
** Thoughts ** To make an even number, there are only even numbers + even numbers and odd numbers + odd numbers, so $ _nC _r $ and $ _mC _r $ are used for N and M, respectively. You can implement the combination calculation yourself, but I used it because it is in scipy.
from scipy.misc import comb
n, m = map(int,input().split())
ans = comb(n,2,exact=True) + comb(m,2,exact=True) #exact=True returns an integer value
print(ans)
** Thoughts ** I was not good at palindromes, so I left it after solving A. If S is a palindrome, we solved it using s.reverse () == s. The strong palindrome condition sliced s and did the same as above. n
s = list(str(input()))
checker = 0
n = len(s)
new_s = list(reversed(s))
if s == new_s:
checker += 1
split_s = s[0:(n-1)//2]
new_s = list(reversed(split_s))
if new_s == split_s:
checker += 1
split_s = s[(n+2)//2:n]
new_s = list(reversed(split_s))
if new_s == split_s:
checker += 1
if checker == 3:
print('Yes')
else:
print('No')
** Thoughts ** The maximum volume is when it becomes a cube, so it ends with $ (L / 3) ^ 3 $. I was afraid of the accuracy, but I passed without doing anything.
l = int(input())
print((l/3)**3)
Problem 1WA、4TLE
** Thoughts ** Couldn't solve I tried to calculate the combination with A without $ A_i $ in the for statement, but I got TLE and died.
from scipy.misc import comb
n = int(input())
a = list(map(int,input().split()))
a_s = set(a)
for i in range(n):
l = a[i]
a[i] = 'X'
ans = 0
for j in a_s:
ans += comb(a.count(j),2,exact=True)
print(ans)
a[i] = l
The cause of the defeat was lack of study and giving up solving B. good night.
Recommended Posts