結果
問題 | No.1318 ABCD quadruplets |
ユーザー | tenten |
提出日時 | 2021-12-06 16:56:38 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 512 ms / 2,000 ms |
コード長 | 3,529 bytes |
コンパイル時間 | 2,240 ms |
コンパイル使用メモリ | 77,648 KB |
実行使用メモリ | 54,560 KB |
最終ジャッジ日時 | 2024-07-07 09:22:58 |
合計ジャッジ時間 | 11,471 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 44 ms
50,008 KB |
testcase_01 | AC | 45 ms
50,276 KB |
testcase_02 | AC | 45 ms
49,888 KB |
testcase_03 | AC | 44 ms
49,784 KB |
testcase_04 | AC | 45 ms
50,100 KB |
testcase_05 | AC | 45 ms
50,132 KB |
testcase_06 | AC | 46 ms
50,280 KB |
testcase_07 | AC | 44 ms
49,980 KB |
testcase_08 | AC | 43 ms
49,816 KB |
testcase_09 | AC | 44 ms
49,984 KB |
testcase_10 | AC | 45 ms
50,188 KB |
testcase_11 | AC | 43 ms
50,084 KB |
testcase_12 | AC | 45 ms
49,892 KB |
testcase_13 | AC | 84 ms
51,544 KB |
testcase_14 | AC | 291 ms
54,560 KB |
testcase_15 | AC | 85 ms
38,528 KB |
testcase_16 | AC | 310 ms
42,536 KB |
testcase_17 | AC | 107 ms
40,148 KB |
testcase_18 | AC | 267 ms
42,592 KB |
testcase_19 | AC | 167 ms
42,176 KB |
testcase_20 | AC | 97 ms
38,696 KB |
testcase_21 | AC | 129 ms
39,556 KB |
testcase_22 | AC | 116 ms
40,808 KB |
testcase_23 | AC | 512 ms
43,672 KB |
testcase_24 | AC | 488 ms
43,688 KB |
testcase_25 | AC | 230 ms
43,996 KB |
testcase_26 | AC | 168 ms
41,400 KB |
testcase_27 | AC | 412 ms
43,624 KB |
testcase_28 | AC | 232 ms
43,552 KB |
testcase_29 | AC | 259 ms
43,068 KB |
testcase_30 | AC | 493 ms
43,768 KB |
testcase_31 | AC | 222 ms
43,724 KB |
testcase_32 | AC | 479 ms
43,544 KB |
ソースコード
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); int m = sc.nextInt(); int[] result = new int[n + 1]; for (int a = 0; a <= m && (a * a) * 8 <= n; a++) { for (int b = a; b <= m && a * a + a * b * 3 + b * b * 4 <= n; b++) { for (int c = b; c <= m && a * a + a * b + a * c * 2 + b * c * 2 + c * c * 2 <= n; c++) { for (int d = c; d <= m && a * a + a * b + a * c + a * d + b * b + b * c + b * d + c * c + c * d + d * d <= n; d++) { int idx = a * a + a * b + a * c + a * d + b * b + b * c + b * d + c * c + c * d + d * d; int ans = 0; if (a == b) { if (b == c) { if (c == d) { ans++; } else { ans += 4; } } else { if (c == d) { ans += 6; } else { ans += 12; } } } else if (b == c) { if (c == d) { ans += 4; } else { ans += 12; } } else if (c == d) { ans += 12; } else { ans += 24; } result[idx] += ans; } } } } StringBuilder sb = new StringBuilder(); for (int x : result) { sb.append(x).append("\n"); } System.out.print(sb); } } class BinaryIndexedTree { int size; int[] tree; public BinaryIndexedTree(int size) { this.size = size; tree = new int[size]; } public void add(int idx, int value) { int mask = 1; while (idx < size) { if ((idx & mask) != 0) { tree[idx] += value; idx += mask; } mask <<= 1; } } public int getSum(int from, int to) { return getSum(to) - getSum(from - 1); } public int getSum(int x) { int mask = 1; int ans = 0; while (x > 0) { if ((x & mask) != 0) { ans += tree[x]; x -= mask; } mask <<= 1; } return ans; } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); 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 String next() throws Exception { if (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }