結果

問題 No.118 門松列(2)
ユーザー tsuchinaga
提出日時 2019-03-25 12:47:17
言語 Go
(1.23.4)
結果
AC  
実行時間 21 ms / 5,000 ms
コード長 630 bytes
コンパイル時間 11,855 ms
コンパイル使用メモリ 237,516 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-07 20:31:10
合計ジャッジ時間 13,347 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

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