結果

問題 No.171 スワップ文字列(Med)
ユーザー AreTrashAreTrash
提出日時 2016-04-15 10:28:07
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 35 ms / 1,000 ms
コード長 1,612 bytes
コンパイル時間 966 ms
コンパイル使用メモリ 114,396 KB
実行使用メモリ 26,684 KB
最終ジャッジ日時 2024-04-15 01:45:19
合計ジャッジ時間 2,016 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
24,516 KB
testcase_01 AC 27 ms
26,684 KB
testcase_02 AC 30 ms
25,044 KB
testcase_03 AC 27 ms
24,528 KB
testcase_04 AC 27 ms
25,044 KB
testcase_05 AC 27 ms
24,500 KB
testcase_06 AC 30 ms
24,524 KB
testcase_07 AC 35 ms
26,576 KB
testcase_08 AC 34 ms
24,788 KB
testcase_09 AC 33 ms
24,656 KB
testcase_10 AC 27 ms
26,564 KB
testcase_11 AC 29 ms
26,568 KB
testcase_12 AC 27 ms
26,564 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