結果

問題 No.3157 Nabeatsu
ユーザー navel_tos
提出日時 2025-05-23 21:12:52
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 164 ms / 2,000 ms
コード長 1,252 bytes
コンパイル時間 515 ms
コンパイル使用メモリ 82,356 KB
実行使用メモリ 121,064 KB
最終ジャッジ日時 2025-05-23 21:12:58
合計ジャッジ時間 6,159 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 45
権限があれば一括ダウンロードができます

ソースコード

diff #

#yukicoder 3155- KCPC新歓杯

'''
#3155
import random
N = int(input())
birthday = [tuple(map(int, input().split())) for _ in range(N)]
birthday.sort()
print('Yes' if any(birthday[i] == birthday[i + 1] for i in range(N - 1)) else 'No')

#3156
K, N = map(int, input().split())
ans = []
for x in range(1, N + 1):
    if (x6 := x ** 6) > N: break
    for y in range(1, N + 1):
        if x6 + (y4 := y ** 4) > N: break
        if (n := x6 + y4) < K: continue
        z2 = n // K
        if K * z2 != n: continue
        z = max(0, int(z2 ** 0.5) - 2)
        while z ** 2 < z2: z += 1
        if z ** 2 != z2: continue
        ans.append(n)
ans.sort()
cnt = 0 if len(ans) == 0 else 1
for i in range(1, len(ans)):
    if ans[i - 1] != ans[i]: cnt += 1
print(cnt)
'''

#3157
N = [int(Si) for Si in input().rstrip()]

while True:
    #最上位の3を検知し、繰り下がりで消す
    for i in range( len(N) ):
        if N[i] == 3:
            N[i] = 2
            for j in range(i + 1, len(N)):N[j] = 9
            break
    if sum(N) % 3 == 0:
        N[-1] -= 1
        for i in range( len(N) - 1, -1, -1 ):
            if N[i] < 0:
                N[i - 1] -= 1
                N[i] += 10
    else: break
print(''.join([str(Si) for Si in N]))


0