1
0

More than 3 years have passed since last update.

yukicoder contest 313 参戦記

Last updated at Posted at 2021-09-10

yukicoder contest 313 参戦記

1時間遅れの参加だったけど、ABCが解けて嬉しかった.

A 1672 404 Not Found

ステータスコードの値を100で割って4か5ならエラーコードですね.

S = int(input())

if S // 100 in [4, 5]:
    print('Yes')
else:
    print('No')

文字列で処理してもいいですけどね.

S = input()

if S[0] in '45':
    print('Yes')
else:
    print('No')

B 1673 Lamps on a line

Ri - Li≦10 という条件なので素直にシミュレーションすればいいです.

from sys import stdin

readline = stdin.readline

N, Q = map(int, readline().split())

c = 0
t = [0] * (N + 1)
result = []
for _ in range(Q):
    L, R = map(int, readline().split())
    for i in range(L - 1, R):
        if t[i] == 0:
            c += 1
            t[i] = 1
        elif t[i] == 1:
            c -= 1
            t[i] = 0
    result.append(c)
print(*result, sep='\n')

C 1674 Introduction to XOR

ちょっと考えると、どの Ai でも立っていない LSB(Least Significant Bit / 最下位ビット)だと分かります.

N, *A = map(int, open(0).read().split())

x = 0
for a in A:
    x |= a

for i in range(x.bit_length() + 1):
    if (x >> i) & 1 == 0:
        print(1 << i)
        break
1
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
1
0