結果
問題 | No.600 かい文回 |
ユーザー |
![]() |
提出日時 | 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 |
ソースコード
import bisectimport copyimport decimalimport fractionsimport heapqimport itertoolsimport mathimport randomimport sysimport timefrom collections import Counter,deque,defaultdictfrom functools import lru_cache,reducefrom heapq import heappush,heappop,heapify,heappushpop,_heappop_max,_heapify_maxdef _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], itemheapq._siftup_max(heap, 0)return itemfrom math import gcd as GCDread=sys.stdin.readreadline=sys.stdin.readlinereadlines=sys.stdin.readlinesdef check(S):N=len(S)ans=0for 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+=1return ansalp=[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()*2n=0while N>=3 and N%2==0:N//=2n+=1N-=1S=lst.pop()return S*(n+1)+main(N)+S*(n+1)N=int(readline())ans=main(N)print(ans)