結果

問題 No.171 スワップ文字列(Med)
ユーザー AreTrashAreTrash
提出日時 2016-04-15 10:28:07
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 65 ms / 1,000 ms
コード長 1,612 bytes
コンパイル時間 5,136 ms
コンパイル使用メモリ 108,484 KB
実行使用メモリ 23,588 KB
最終ジャッジ日時 2023-07-27 13:52:32
合計ジャッジ時間 4,258 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 58 ms
21,556 KB
testcase_01 AC 56 ms
23,588 KB
testcase_02 AC 62 ms
21,560 KB
testcase_03 AC 57 ms
19,476 KB
testcase_04 AC 58 ms
23,468 KB
testcase_05 AC 58 ms
21,564 KB
testcase_06 AC 61 ms
21,456 KB
testcase_07 AC 64 ms
21,460 KB
testcase_08 AC 65 ms
23,528 KB
testcase_09 AC 62 ms
21,440 KB
testcase_10 AC 57 ms
23,524 KB
testcase_11 AC 57 ms
23,568 KB
testcase_12 AC 56 ms
21,480 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.Linq;

namespace No171_1{
    public class Program{
        public static void Main(string[] args){
            const int mod = 573;

            var str = Console.ReadLine();
            var length = str.Length;
            var charCount = new int[26];
            var facSeq = Enumerable.Range(1, length).ToArray();

            foreach(var s in str){
                charCount[s - 'A']++;
            }

            Func<int, List<int>> func = n =>{
                var tmp = n;
                var list = new List<int>();
                for(var i = 2; i * i <= tmp; i++){
                    while(tmp % i == 0){
                        tmp /= i;
                        list.Add(i);
                    }
                }
                if(tmp > 1) list.Add(tmp);
                return list;
            };

            foreach(var cc in charCount){
                for(var i = 2; i <= cc; i++){
                    foreach(var j in func(i)){
                        for(var k = 0; k < length; k++) {
                            if(facSeq[k] % j == 0) {
                                facSeq[k] /= j;
                                break;
                            }
                        }
                    }
                }
            }

            var result = 1;

            foreach(var fac in facSeq){
                result *= fac;
                while(result >= mod){
                    result -= mod;
                }
            }

            Console.WriteLine(result == 0 ? mod - 1 : result - 1);
        }
    }
}
0