結果

問題 No.118 門松列(2)
ユーザー tsuchinagatsuchinaga
提出日時 2019-03-25 12:47:17
言語 Go
(1.22.1)
結果
AC  
実行時間 21 ms / 5,000 ms
コード長 630 bytes
コンパイル時間 16,380 ms
コンパイル使用メモリ 226,524 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-16 19:20:52
合計ジャッジ時間 14,700 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

package main

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

func main() {
	var n, a int
	_, _ = fmt.Scan(&n)
	mod := int(math.Pow10(9)) + 7

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	ls := make([]int, 0)
	bs := make(map[int]int, 0)
	for i := 0; i < n; i++ {
		sc.Scan()
		a, _ = strconv.Atoi(sc.Text())
		if _, ok := bs[a]; !ok {
			ls = append(ls, a)
		}
		bs[a]++
	}

	// fmt.Println(ls, bs)

	cnt := 0
	for i := 0; i < len(ls)-2; i++ {
		for j := i + 1; j < len(ls)-1; j++ {
			for k := j + 1; k < len(ls); k++ {
				cnt = (cnt + bs[ls[i]]*bs[ls[j]]*bs[ls[k]]) % mod
			}
		}
	}
	fmt.Println(cnt)
}
0