結果

問題 No.118 門松列(2)
ユーザー tyochiaityochiai
提出日時 2015-01-19 04:26:19
言語 Go
(1.22.1)
結果
WA  
実行時間 -
コード長 684 bytes
コンパイル時間 13,189 ms
コンパイル使用メモリ 240,976 KB
実行使用メモリ 7,840 KB
最終ジャッジ日時 2024-04-18 09:38:46
合計ジャッジ時間 17,722 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import (
	"fmt"
	"math"
)

func LenComb2(n int) float64 {
	return float64(n*(n-1)) / float64(2*1)
}

func LenComb3(n int) float64 {
	return float64(n*(n-1)*(n-2)) / float64(3*2*1)
}

func resolve(N int, A []int) int {
	B := make([]int, 101)
	for i := 0; i < N; i++ {
		B[A[i]] += 1
	}

	ret := LenComb3(N)
	for _, m := range B {
		if m <= 1 {
			continue
		}
		if m == 2 {
			ret -= float64(N - 2)
			continue
		}
		ret -= LenComb2(m)*float64(N-m) + LenComb3(m)
	}
	return int(math.Mod(ret, float64(100000007)))
}

func main() {
	var N int

	fmt.Scanf("%d\n", &N)
	A := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &A[i])
	}

	fmt.Println(resolve(N, A))
}
0