LoginSignup
3
1

More than 3 years have passed since last update.

AtCoder 第二回日本最強プログラマー学生選手権 参戦記

Last updated at Posted at 2021-04-17

AtCoder 第二回日本最強プログラマー学生選手権 参戦記

難易度絶壁の直前に数学問題置くのやめて……. 久々の三桁パフォ…….

JSC2021A - Competition

3分で突破. 書くだけ.

X, Y, Z = map(int, input().split())

print((Y * Z - 1) // X)

JSC2021B - Xor of Sequences

3分で突破. 書くだけ.

N, M = map(int, input().split())
A = set(map(int, input().split()))
B = set(map(int, input().split()))

print(*sorted(A ^ B))

JSC2021C - Max GCD 2

9分で突破. B≤2×105 だからシングルループは OK. GCD を a と置くと x は A 以上の最小の a の倍数とし、y は x + a として、y ≤ B であれば、その a は答えとして有効であるということになる. あとは B までループを回してやれよい.

A, B = map(int, input().split())

for a in range(1, B + 1):
    x = (A + (a - 1)) // a * a
    y = x + a
    if y > B:
        continue
    result = a
print(result)

JSC2021D - Nowhere P

64分で突破. Wolfram|Alphag(1)=P-1, g(n+1) = g(n) * (P-2) を入力したら g(n) = (P - 1)(P - 2)n-1 と教えてくれたので解けた.

m = 1000000007

N, P = map(int, input().split())

print((P - 1) * pow(P - 2, N - 1, m) % m)
3
1
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
3
1