結果

問題 No.171 スワップ文字列(Med)
ユーザー takakintakakin
提出日時 2020-06-11 00:20:11
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 578 bytes
コンパイル時間 86 ms
コンパイル使用メモリ 10,908 KB
実行使用メモリ 7,936 KB
最終ジャッジ日時 2023-09-06 01:25:46
合計ジャッジ時間 1,248 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,932 KB
testcase_01 AC 15 ms
7,928 KB
testcase_02 WA -
testcase_03 AC 16 ms
7,796 KB
testcase_04 AC 16 ms
7,936 KB
testcase_05 AC 16 ms
7,796 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 16 ms
7,844 KB
testcase_09 AC 16 ms
7,840 KB
testcase_10 AC 15 ms
7,804 KB
testcase_11 AC 16 ms
7,772 KB
testcase_12 AC 16 ms
7,840 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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