結果
| 問題 |
No.170 スワップ文字列(Easy)
|
| コンテスト | |
| ユーザー |
bluemegane
|
| 提出日時 | 2018-10-05 10:39:38 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 27 ms / 5,000 ms |
| コード長 | 998 bytes |
| コンパイル時間 | 867 ms |
| コンパイル使用メモリ | 111,352 KB |
| 実行使用メモリ | 25,960 KB |
| 最終ジャッジ日時 | 2024-10-12 12:31:11 |
| 合計ジャッジ時間 | 2,635 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System.Collections.Generic;
using System;
public class Hello
{
public static void Main()
{
var s = Console.ReadLine().Trim();
var sL = s.Length;
if (sL == 1) { Console.WriteLine(0); goto end; }
if (sL == 2)
if (s[0] == s[1]) { Console.WriteLine(0); goto end; }
else { Console.WriteLine(1); goto end; }
Console.WriteLine(getAns(s));
end:;
}
public static int getAns(string s)
{
var d = new Dictionary<char, int>();
foreach (var x in s)
if (d.ContainsKey(x)) d[x]++;
else d[x] = 1;
var ans = getFact(s.Length);
foreach (var x in d)
if (x.Value >= 2) ans /= getFact(x.Value);
return ans - 1;
}
public static int getFact(int n)
{
if (n == 1) return 1;
if (n == 2) return 2;
if (n == 3) return 6;
var ans = 6;
for (int i = 4; i <= n; i++) ans *= i;
return ans;
}
}
bluemegane