結果

問題 No.171 スワップ文字列(Med)
ユーザー 6soukiti296soukiti29
提出日時 2017-10-21 20:08:07
言語 Nim
(2.0.0)
結果
AC  
実行時間 6 ms / 1,000 ms
コード長 757 bytes
コンパイル時間 3,057 ms
コンパイル使用メモリ 68,760 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-12 15:21:04
合計ジャッジ時間 4,024 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 4 ms
4,380 KB
testcase_07 AC 2 ms
4,384 KB
testcase_08 AC 6 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
/home/judge/data/code/Main.nim(1, 8) Warning: imported and not used: 'sequtils' [UnusedImport]
/home/judge/data/code/Main.nim(1, 17) Warning: imported and not used: 'strutils' [UnusedImport]

ソースコード

diff #

import sequtils,strutils,math

proc combi(n, t, m : int) : int =
    var
        t = min(t, n - t)
        A = newSeq[int](0)
    if t < 0:
        return 0
    elif t == 0:
        return 1
    elif t == 1:
        return n
    for i in 0..<t:
        A.add(n - i)
    for i in 1..t:
        var
            p = i
            j = 0
        while p > 1:
            var g = gcd(A[j], p)
            p = p div g
            A[j] = A[j] div g
            j += 1
    result = 1
    for a in A:
        result = (result * a) mod m
    
var
    S = stdin.readline
    cnt : array['A' .. 'Z' , int]
    ans = 1
    l = S.len

for c in S:
    cnt[c] += 1

for c in cnt:
    ans = (ans * combi(l, c, 573)) mod 573
    l -= c
if ans == 0:
    ans += 573
echo ans - 1
0