1
1

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 264 参戦記

Last updated at Posted at 2020-09-04

yukicoder contest 264 参戦記

A 1217 せしすせそ

ループを回して、一致しないインデックスを求めて、XtoY を出力するだけ.

S = input()

for i in range(26):
    a = chr(i + ord('a'))
    if S[i] == a:
        continue
    print('%sto%s' % (a, S[i]))
    break

B 1218 Something Like a Theorem

何も考えずに全探索しても TLE にならなくて、あれってなった.

n, z = map(int, input().split())

for x in range(1, z + 1):
    for y in range(x, z + 1):
        if x ** n + y ** n == z ** n:
            print('Yes')
            exit()
print('No')

C 1219 Mancala Combo

操作としては一番左側の Ai=i を操作してを繰り返すわけだけど、もちろんナイーブにそれをシミュレートする実装をすると TLE になる(なお、heapq で実装して体験しました orz). よくよく考えると、Ai より右の Ai+1~AN を消した回数だけ積み増されるので、その積み増しを c とした時に c + Ai が i の倍数になっていればいい. c を積みながら右からスキャンすると O(N) となって解ける.

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

c = 0
for i in range(N - 1, -1, -1):
    if (A[i] + c) % (i + 1) != 0:
        print('No')
        break
    c += (A[i] + c) // (i + 1)
else:
    print('Yes')
1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?