結果

問題 No.118 門松列(2)
ユーザー ぴろずぴろず
提出日時 2016-02-18 15:44:11
言語 Java21
(openjdk 21)
結果
AC  
実行時間 573 ms / 5,000 ms
コード長 487 bytes
コンパイル時間 2,676 ms
コンパイル使用メモリ 74,340 KB
実行使用メモリ 48,368 KB
最終ジャッジ日時 2024-04-17 13:53:44
合計ジャッジ時間 13,165 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 217 ms
46,172 KB
testcase_01 AC 573 ms
48,068 KB
testcase_02 AC 544 ms
48,152 KB
testcase_03 AC 560 ms
48,244 KB
testcase_04 AC 521 ms
48,052 KB
testcase_05 AC 566 ms
48,368 KB
testcase_06 AC 129 ms
41,720 KB
testcase_07 AC 126 ms
41,500 KB
testcase_08 AC 130 ms
41,328 KB
testcase_09 AC 572 ms
48,168 KB
testcase_10 AC 285 ms
47,660 KB
testcase_11 AC 333 ms
47,748 KB
testcase_12 AC 264 ms
47,444 KB
testcase_13 AC 236 ms
46,260 KB
testcase_14 AC 539 ms
48,228 KB
testcase_15 AC 188 ms
43,616 KB
testcase_16 AC 424 ms
47,968 KB
testcase_17 AC 227 ms
46,068 KB
testcase_18 AC 329 ms
47,928 KB
testcase_19 AC 447 ms
47,680 KB
testcase_20 AC 430 ms
48,228 KB
testcase_21 AC 464 ms
47,752 KB
testcase_22 AC 298 ms
47,376 KB
testcase_23 AC 514 ms
47,816 KB
testcase_24 AC 346 ms
47,980 KB
testcase_25 AC 446 ms
48,064 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package no118a;

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[100];
		for(int i=0;i<n;i++) {
			a[sc.nextInt()-1]++;
		}
		long s = n;
		long sq = 0;
		long cb = 0;
		for(int i=0;i<100;i++) {
			sq += (long) a[i] * a[i];
			cb += (long) a[i] * a[i] * a[i];
		}
		long ans = (s * s * s - 3 * s * sq + 2 * cb) / 6;
		System.out.println(ans % 1000000007);
	}

}
0