結果

問題 No.600 かい文回
ユーザー vwxyz
提出日時 2022-08-08 16:25:00
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 46 ms / 2,000 ms
コード長 1,481 bytes
コンパイル時間 101 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 12,032 KB
最終ジャッジ日時 2024-09-19 02:15:43
合計ジャッジ時間 2,542 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

import bisect
import copy
import decimal
import fractions
import heapq
import itertools
import math
import random
import sys
import time
from collections import Counter,deque,defaultdict
from functools import lru_cache,reduce
from heapq import heappush,heappop,heapify,heappushpop,_heappop_max,_heapify_max
def _heappush_max(heap,item):
    heap.append(item)
    heapq._siftdown_max(heap, 0, len(heap)-1)
def _heappushpop_max(heap, item):
    if heap and item < heap[0]:
        item, heap[0] = heap[0], item
        heapq._siftup_max(heap, 0)
    return item
from math import gcd as GCD
read=sys.stdin.read
readline=sys.stdin.readline
readlines=sys.stdin.readlines

def check(S):
    N=len(S)
    ans=0
    for bit in range(1<<N//2):
        bound=[0]+[i+1 for i in range(N-1) if bit&1<<i]
        if N%2:
            bound+=[N-i for i in bound[::-1]]
        elif N//2==bound[-1]:
            bound+=[N-i for i in bound[:-1][::-1]]
        else:
            bound+=[N-i for i in bound[::-1]]
        le=len(bound)
        lst=[S[bound[i]:bound[i+1]] for i in range(le-1)]
        if lst==lst[::-1]:
            ans+=1
    return ans

alp=[chr(i) for i in range(97,97+26)]
lst=[a+b for a in alp[:3] for b in alp[3:7]]+alp[7:]
def main(N):
    if N==1:
        return lst.pop()
    if N==2:
        return lst.pop()*2
    n=0
    while N>=3 and N%2==0:
        N//=2
        n+=1
    N-=1
    S=lst.pop()
    return S*(n+1)+main(N)+S*(n+1)

N=int(readline())
ans=main(N)
print(ans)
0