0
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 303 参戦記

Posted at

yukicoder contest 303 参戦記

A 1585 Cubic Number

N≦1018 なので、シングルループで一発ではある.

N = int(input())

for i in range(1, 10 ** 6 + 1):
    if i ** 3 != N:
        continue
    print('Yes')
    break
else:
    print('No')

にぶたんでもいい.

N = int(input())

ok = 0
ng = 10 ** 6 + 1
while ng - ok > 1:
    m = ok + (ng - ok) // 2
    if m ** 3 <= N:
        ok = m
    else:
        ng = m
if ok ** 3 == N:
    print('Yes')
else:
    print('No')

三乗根を取って、その近辺をチェックしてもいい.

N = int(input())

n = int(N ** (1 / 3))
for i in range(n - 1, n + 1 + 1):
    if i ** 3 != N:
        continue
    print('Yes')
    break
else:
    print('No')

B 1586 Equal Array

操作自体が +1 と -1 の組で、トータルでは±0なので、合計が N の倍数になっているかが全て.

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

if sum(A) % N == 0:
    print('Yes')
else:
    print('No')
0
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
0
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?