結果
問題 | No.2203 POWER!!!!! |
ユーザー | tenten |
提出日時 | 2023-04-21 11:37:00 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 216 ms / 2,000 ms |
コード長 | 1,945 bytes |
コンパイル時間 | 2,835 ms |
コンパイル使用メモリ | 90,792 KB |
実行使用メモリ | 45,160 KB |
最終ジャッジ日時 | 2024-04-24 01:17:04 |
合計ジャッジ時間 | 6,329 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 53 ms
37,124 KB |
testcase_01 | AC | 53 ms
37,116 KB |
testcase_02 | AC | 52 ms
36,988 KB |
testcase_03 | AC | 53 ms
36,968 KB |
testcase_04 | AC | 53 ms
37,060 KB |
testcase_05 | AC | 54 ms
37,016 KB |
testcase_06 | AC | 55 ms
37,052 KB |
testcase_07 | AC | 53 ms
37,084 KB |
testcase_08 | AC | 101 ms
39,876 KB |
testcase_09 | AC | 139 ms
42,812 KB |
testcase_10 | AC | 171 ms
44,496 KB |
testcase_11 | AC | 208 ms
44,856 KB |
testcase_12 | AC | 110 ms
39,764 KB |
testcase_13 | AC | 198 ms
44,824 KB |
testcase_14 | AC | 216 ms
45,116 KB |
testcase_15 | AC | 215 ms
45,160 KB |
testcase_16 | AC | 196 ms
44,384 KB |
testcase_17 | AC | 202 ms
44,360 KB |
testcase_18 | AC | 52 ms
36,872 KB |
testcase_19 | AC | 55 ms
36,884 KB |
testcase_20 | AC | 53 ms
36,884 KB |
ソースコード
import java.io.*; import java.util.*; import java.util.stream.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); long[] counts = new long[9]; for (int i = 0; i < n; i++) { counts[sc.nextInt()]++; } long ans = 0; for (int i = 1; i <= 8; i++) { for (int j = 1; j <= 8; j++) { ans += pow(i, j) * counts[i] * counts[j]; } } System.out.println(ans); } static long pow(int x, int p) { if (p == 0) { return 1; } else { return pow(x, p - 1) * x; } } } class Utilities { static String arrayToLineString(Object[] arr) { return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n")); } static String arrayToLineString(int[] arr) { return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new)); } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public int[] nextIntArray() throws Exception { return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray(); } public String next() throws Exception { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }