0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

yukicoder contest 309 参戦記

Posted at

yukicoder contest 309 参戦記

A 1642 Registration

自分が使っている言語の書式指定子を知っているかだけですね.

N = int(input())

print('%03d' % N)

B 1643 Not Substring

文字列を辞書順に並べると、'a', 'aa', 'aaa', 'aaaa', ... となる. 後は 'a' を幾つ並べるとSの部分列では無くなるかを考えれば 'a' の個数を数えて、それより1つ長くすればいいと分かるはず.

S = input()

print('a' * (S.count('a') + 1))

C 1644 Eight Digits

8! ≒ 4.0×104 なので、総当りしても TLE しないので、総当たりすれば良いと分かる.

from itertools import permutations

K = int(input())

result = 0
for p in permutations('12345678'):
    if int(''.join(p)) % K == 0:
        result += 1
print(result)

D 1645 AB's abs

N≦100で、Ai≦100なのを見たらナップサック問題かなってなりますよね.

from collections import defaultdict

m = 998244353

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

d = {0: 1}
for a in A:
    t = defaultdict(int)
    for k in d:
        t[k + a] += d[k]
        t[k + a] %= m
        t[k - a] += d[k]
        t[k - a] %= m
    d = t

result = 0
for k in d:
    result += abs(k) * d[k]
    result %= m
print(result)
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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?