結果

問題 No.118 門松列(2)
ユーザー YamaKasaYamaKasa
提出日時 2018-07-11 20:57:17
言語 Java21
(openjdk 21)
結果
AC  
実行時間 510 ms / 5,000 ms
コード長 589 bytes
コンパイル時間 3,552 ms
コンパイル使用メモリ 74,864 KB
実行使用メモリ 62,084 KB
最終ジャッジ日時 2023-10-21 19:19:13
合計ジャッジ時間 14,453 ms
ジャッジサーバーID
(参考情報)
judge10 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 230 ms
60,760 KB
testcase_01 AC 480 ms
62,072 KB
testcase_02 AC 475 ms
62,080 KB
testcase_03 AC 477 ms
62,084 KB
testcase_04 AC 510 ms
62,020 KB
testcase_05 AC 472 ms
62,076 KB
testcase_06 AC 131 ms
57,568 KB
testcase_07 AC 131 ms
57,472 KB
testcase_08 AC 132 ms
57,316 KB
testcase_09 AC 468 ms
61,976 KB
testcase_10 AC 300 ms
61,820 KB
testcase_11 AC 319 ms
61,984 KB
testcase_12 AC 266 ms
61,136 KB
testcase_13 AC 243 ms
60,600 KB
testcase_14 AC 465 ms
61,792 KB
testcase_15 AC 204 ms
59,696 KB
testcase_16 AC 398 ms
61,956 KB
testcase_17 AC 238 ms
60,620 KB
testcase_18 AC 336 ms
61,892 KB
testcase_19 AC 396 ms
61,824 KB
testcase_20 AC 386 ms
61,804 KB
testcase_21 AC 440 ms
61,988 KB
testcase_22 AC 325 ms
61,788 KB
testcase_23 AC 427 ms
61,720 KB
testcase_24 AC 329 ms
61,872 KB
testcase_25 AC 369 ms
61,796 KB
権限があれば一括ダウンロードができます

ソースコード

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