結果

問題 No.118 門松列(2)
ユーザー ぴろずぴろず
提出日時 2015-01-07 00:19:55
言語 Java19
(openjdk 21)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 473 bytes
コンパイル時間 2,678 ms
コンパイル使用メモリ 71,532 KB
実行使用メモリ 60,476 KB
最終ジャッジ日時 2023-09-03 22:12:46
合計ジャッジ時間 12,295 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 469 ms
60,416 KB
testcase_02 AC 441 ms
60,380 KB
testcase_03 AC 439 ms
60,388 KB
testcase_04 AC 439 ms
60,376 KB
testcase_05 AC 438 ms
60,476 KB
testcase_06 AC 121 ms
55,580 KB
testcase_07 AC 119 ms
55,724 KB
testcase_08 AC 119 ms
55,660 KB
testcase_09 AC 468 ms
60,328 KB
testcase_10 AC 269 ms
60,108 KB
testcase_11 AC 295 ms
60,172 KB
testcase_12 AC 251 ms
59,688 KB
testcase_13 AC 224 ms
59,308 KB
testcase_14 AC 434 ms
60,164 KB
testcase_15 AC 189 ms
58,696 KB
testcase_16 AC 387 ms
60,180 KB
testcase_17 AC 214 ms
59,472 KB
testcase_18 AC 295 ms
60,180 KB
testcase_19 AC 368 ms
60,216 KB
testcase_20 AC 358 ms
60,412 KB
testcase_21 AC 437 ms
60,312 KB
testcase_22 AC 287 ms
60,352 KB
testcase_23 AC 378 ms
60,120 KB
testcase_24 AC 301 ms
60,192 KB
testcase_25 AC 358 ms
60,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 += a[i] * a[i];
			cb += a[i] * a[i] * a[i];
		}
		long ans = (s * s * s - 3 * s * sq + 2 * cb) / 6;
		System.out.println(ans % 1000000007);
	}

}
0