結果

問題 No.171 スワップ文字列(Med)
ユーザー yuki2006yuki2006
提出日時 2015-04-02 21:12:41
言語 Go
(1.22.1)
結果
AC  
実行時間 6 ms / 1,000 ms
コード長 1,350 bytes
コンパイル時間 12,918 ms
コンパイル使用メモリ 235,148 KB
実行使用メモリ 7,936 KB
最終ジャッジ日時 2024-04-18 10:23:39
合計ジャッジ時間 12,140 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,248 KB
testcase_02 AC 3 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 3 ms
5,376 KB
testcase_06 AC 4 ms
5,760 KB
testcase_07 AC 5 ms
7,424 KB
testcase_08 AC 6 ms
7,936 KB
testcase_09 AC 6 ms
7,936 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import (
	"bufio"
	"os"
	"strconv"
	"strings"
	"fmt"
)

var s = bufio.NewScanner(os.Stdin)

func next() string {

	s.Split(bufio.ScanWords)
	s.Scan()
	return s.Text()
}
func nextLine() string {
	s.Split(bufio.ScanLines)
	s.Scan()
	if nil != s.Err() {
		panic(s.Err())
	}
	return s.Text()
}

func nextInt() int {
	i, e := strconv.Atoi(next())
	if e != nil {
		panic(e)
	}
	return i
}
func nextLong() int64 {
	i, e := strconv.ParseInt(next(), 10, 64)
	if e != nil {
		panic(e)
	}
	return i
}

//パスカルの三角形でコンビネーション計算
func nCr(n int) [][]int {
	var dp = make([][]int, n+10)
	dp[0] = make([]int, n+10)
	dp[0][0] = 1
	for i := 1; i <= n; i++ {
		dp[i] = make([]int, n+10)
		dp[i][0] = dp[i-1][0]
		for j := i; j > 0; j-- {
			dp[i][j] = dp[i-1][j]+dp[i-1][j-1]
			dp[i][j]%=573
		}
	}
	return dp
}

func mapToString(arr []int) []string {
	ret := make([]string, len(arr))
	for i := 0; i < len(arr); i++ {
		ret[i] = strconv.Itoa(arr[i])
	}
	return ret
}


func PrintI(args ...int) {
	fmt.Println(strings.Join(mapToString(args), " "))
}


func main() {
	S := nextLine()
	var set = map[rune]int{}

	for _, s := range S {
		set[s]+=1
	}

	var leng = len(S)
	dp := nCr(len(S))

	sum := 1
	for _, v := range set {
		sum*=dp[leng][v]
		leng-=v
		sum%=573
		if sum == 0 {
			sum = 573
		}
	}

	PrintI(sum-1)
}



0