結果

問題 No.118 門松列(2)
ユーザー YamaKasa
提出日時 2018-07-11 20:57:17
言語 Java
(openjdk 23)
結果
AC  
実行時間 542 ms / 5,000 ms
コード長 589 bytes
コンパイル時間 1,905 ms
コンパイル使用メモリ 74,300 KB
実行使用メモリ 47,884 KB
最終ジャッジ日時 2024-09-21 20:40:16
合計ジャッジ時間 12,110 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		long []cnt = new long[101];
		Arrays.fill(cnt, 0);
		for(int i = 0; i < N; i++) {
			cnt[scan.nextInt()]++;
		}
		scan.close();

		long s1 = 0;
		long s2 = 0;
		long s3 = 0;
		for(int i = 1; i <= 100; i++) {
			s1 += cnt[i];
			s2 += cnt[i] * cnt[i];
			s3 += cnt[i] * cnt[i] * cnt[i];
		}
		long ans = (s1 * s1 * s1 -3 * s1 * s2 + 2 * s3)/ 6;
		long d = 1000000007L;
		System.out.println(ans % d);



	}
}
0