結果
問題 | No.1318 ABCD quadruplets |
ユーザー | tenten |
提出日時 | 2021-12-06 16:56:38 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 629 ms / 2,000 ms |
コード長 | 3,529 bytes |
コンパイル時間 | 2,273 ms |
コンパイル使用メモリ | 74,256 KB |
実行使用メモリ | 57,276 KB |
最終ジャッジ日時 | 2023-09-21 15:36:57 |
合計ジャッジ時間 | 12,373 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 40 ms
49,384 KB |
testcase_01 | AC | 40 ms
49,592 KB |
testcase_02 | AC | 40 ms
49,312 KB |
testcase_03 | AC | 40 ms
49,372 KB |
testcase_04 | AC | 41 ms
49,260 KB |
testcase_05 | AC | 42 ms
49,220 KB |
testcase_06 | AC | 41 ms
49,372 KB |
testcase_07 | AC | 40 ms
49,276 KB |
testcase_08 | AC | 41 ms
49,520 KB |
testcase_09 | AC | 40 ms
49,188 KB |
testcase_10 | AC | 41 ms
49,296 KB |
testcase_11 | AC | 41 ms
49,212 KB |
testcase_12 | AC | 40 ms
49,228 KB |
testcase_13 | AC | 90 ms
52,124 KB |
testcase_14 | AC | 331 ms
54,956 KB |
testcase_15 | AC | 84 ms
51,100 KB |
testcase_16 | AC | 342 ms
54,988 KB |
testcase_17 | AC | 113 ms
52,648 KB |
testcase_18 | AC | 317 ms
55,012 KB |
testcase_19 | AC | 178 ms
54,508 KB |
testcase_20 | AC | 93 ms
52,248 KB |
testcase_21 | AC | 136 ms
52,420 KB |
testcase_22 | AC | 117 ms
54,372 KB |
testcase_23 | AC | 572 ms
57,000 KB |
testcase_24 | AC | 579 ms
57,276 KB |
testcase_25 | AC | 229 ms
57,276 KB |
testcase_26 | AC | 201 ms
55,056 KB |
testcase_27 | AC | 475 ms
56,992 KB |
testcase_28 | AC | 253 ms
57,044 KB |
testcase_29 | AC | 282 ms
56,644 KB |
testcase_30 | AC | 579 ms
57,080 KB |
testcase_31 | AC | 238 ms
57,252 KB |
testcase_32 | AC | 629 ms
57,132 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(); } }