結果

問題 No.171 スワップ文字列(Med)
ユーザー maimai
提出日時 2016-06-13 19:33:40
言語 Ruby
(3.3.0)
結果
AC  
実行時間 163 ms / 1,000 ms
コード長 378 bytes
コンパイル時間 106 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 12,288 KB
最終ジャッジ日時 2024-04-17 19:07:16
合計ジャッジ時間 2,245 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 91 ms
12,160 KB
testcase_01 AC 91 ms
12,288 KB
testcase_02 AC 115 ms
12,288 KB
testcase_03 AC 90 ms
11,904 KB
testcase_04 AC 91 ms
12,160 KB
testcase_05 AC 106 ms
12,288 KB
testcase_06 AC 132 ms
12,160 KB
testcase_07 AC 153 ms
12,160 KB
testcase_08 AC 163 ms
12,160 KB
testcase_09 AC 163 ms
12,032 KB
testcase_10 AC 92 ms
12,160 KB
testcase_11 AC 93 ms
12,032 KB
testcase_12 AC 93 ms
11,904 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

s=gets.chomp
if s.size==1
    p 0;exit
end

ac={}
s.chars.each{|c|
    ac[c]=0 if !ac[c]
    ac[c]+=1
}

a=(2..s.size).to_a

ac.each{|e|
    (2..e[1]).each{|u|
        a.map!{|e|
            break if u<=1
            g=u.gcd(e)
            if g>1
                e=e/g
                u=u/g
            end
            e
        }
    }
}

e = a.inject(:*)%573-1
p e<0 ? 572 : e
0