結果

問題 No.171 スワップ文字列(Med)
コンテスト
ユーザー takakin
提出日時 2020-06-11 00:20:11
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
WA  
実行時間 -
コード長 578 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 329 ms
コンパイル使用メモリ 20,828 KB
実行使用メモリ 15,616 KB
最終ジャッジ日時 2026-03-09 03:46:51
合計ジャッジ時間 2,241 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 7 WA * 3
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import sys
input=lambda: sys.stdin.readline().rstrip()
S=input()
n=len(S)
n_max=n
D=[0]*26
for s in S:
  D[ord(s)-65]+=1

def ans(mod):
  
  F,FI=[0]*(n_max+1),[0]*(n_max+1)
  F[0],FI[0]=1,1
  for i in range(n_max):
    F[i+1]=(F[i]*(i+1))%mod
  FI[n_max-1]=pow(F[n_max-1],mod-2,mod)
  for i in reversed(range(n_max-1)):
    FI[i]=(FI[i+1]*(i+1))%mod
  ret=F[n]
  for i in range(26):
    ret=(ret*FI[D[i]])%mod
  return (ret-1)%mod

if max(D)==n:
  print(0)
else:
  ans1,ans2=ans(3),ans(191)
  for i in range(573):
    if i%3==ans1 and i%191==ans2:
      print(i)
      break


0