結果

問題 No.118 門松列(2)
ユーザー tnoda_tnoda_
提出日時 2015-01-25 16:42:02
言語 Go
(1.22.1)
結果
AC  
実行時間 299 ms / 5,000 ms
コード長 429 bytes
コンパイル時間 12,657 ms
コンパイル使用メモリ 236,380 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2024-04-18 09:52:06
合計ジャッジ時間 14,817 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
6,812 KB
testcase_01 AC 299 ms
7,844 KB
testcase_02 AC 289 ms
7,840 KB
testcase_03 AC 298 ms
7,840 KB
testcase_04 AC 294 ms
7,844 KB
testcase_05 AC 297 ms
7,844 KB
testcase_06 AC 1 ms
6,940 KB
testcase_07 AC 1 ms
6,944 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 288 ms
7,840 KB
testcase_10 AC 60 ms
6,944 KB
testcase_11 AC 79 ms
6,940 KB
testcase_12 AC 42 ms
6,944 KB
testcase_13 AC 27 ms
6,940 KB
testcase_14 AC 277 ms
7,840 KB
testcase_15 AC 7 ms
6,940 KB
testcase_16 AC 166 ms
6,940 KB
testcase_17 AC 23 ms
6,940 KB
testcase_18 AC 80 ms
6,940 KB
testcase_19 AC 133 ms
6,940 KB
testcase_20 AC 143 ms
6,944 KB
testcase_21 AC 228 ms
7,840 KB
testcase_22 AC 65 ms
6,940 KB
testcase_23 AC 205 ms
7,844 KB
testcase_24 AC 88 ms
6,940 KB
testcase_25 AC 126 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import (
	"fmt"
)

// Prime number
const P = 1000000007

func main() {
	var n, z int64
	m := make(map[int64]int64)
	fmt.Scan(&n)
	z = n * (n - 1) * (n - 2) / 6
	for i := int64(0); i < n; i++ {
		var a int64
		fmt.Scan(&a)
		m[a]++
	}
	for _, x := range m {
		if x < 2 {
			continue
		}
		if x >= 2 {
			z -= (n - x) * x * (x - 1) / 2
		}
		if x >= 3 {
			z -= x * (x - 1) * (x - 2) / 6
		}
	}
	fmt.Println(z % P)
}
0