LoginSignup
0
0

More than 3 years have passed since last update.

AtCoder Beginner Contest 132をといてみた

Posted at

A - Fifty-Fifty

入力例

ASSA
import collections
list = list(input())
c = collections.Counter(list)
count = 0

for k,v in c.items():
    if v == 2:
        count = count +1

if count == 2:
    print("Yes")
else:
    print("No")

B - Ordinary Number

入力例

5
1 3 5 4 2

C - Divide the Problems

6
9 1 4 4 6 7

N = int(input())
numbers = list(map(int, input().split()))

result = 0

for count in range(N-2):
    sliced_list = numbers[:3]
    if min(sliced_list) != sliced_list[1] and max(sliced_list) != sliced_list[1]:
        result = result + 1
    numbers.pop(0)
print(result)
N = int(input())
levels = list(map(int, input().split()))
#print(levels)
levels.sort()
#print(levels)

divid_number = int(N/2)
#print(levels[divid_number-1])
#print(levels[divid_number])
print(levels[divid_number]-levels[divid_number-1])


D - Blue and Red Balls

入力例

5 3

回答例

きっと場合分けを頑張るんだろうなと思ったけどボールの数が多くなれば多くなるほどどうすれば良いのかわからなくて困っていた

import math
N, K = map(int, input().split())

print((N-K+1)%(1000000000+7))
print(math.factorial(N-K+1)%(1000000000+7))
print(math.factorial(N-K-2+1)%(1000000000+7))
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0