結果

問題 No.1318 ABCD quadruplets
ユーザー KudeKude
提出日時 2020-12-15 23:07:25
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 194 ms / 2,000 ms
コード長 1,862 bytes
コンパイル時間 2,029 ms
コンパイル使用メモリ 202,516 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-20 06:53:08
合計ジャッジ時間 5,643 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 3 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 6 ms
4,348 KB
testcase_14 AC 78 ms
4,348 KB
testcase_15 AC 3 ms
4,348 KB
testcase_16 AC 101 ms
4,348 KB
testcase_17 AC 10 ms
4,348 KB
testcase_18 AC 70 ms
4,348 KB
testcase_19 AC 33 ms
4,348 KB
testcase_20 AC 6 ms
4,348 KB
testcase_21 AC 15 ms
4,348 KB
testcase_22 AC 11 ms
4,348 KB
testcase_23 AC 192 ms
4,348 KB
testcase_24 AC 176 ms
4,348 KB
testcase_25 AC 45 ms
4,348 KB
testcase_26 AC 27 ms
4,348 KB
testcase_27 AC 133 ms
4,348 KB
testcase_28 AC 53 ms
4,348 KB
testcase_29 AC 63 ms
4,348 KB
testcase_30 AC 193 ms
4,348 KB
testcase_31 AC 48 ms
4,348 KB
testcase_32 AC 194 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n)for (int i = 0; i < (n); ++i)

int hist[160001], ans[160001];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    rep(a, m + 1) {
        int tot1 = a * a;
        rep(b, a) {
            int s2 = a + b;
            int tot2 = tot1 + s2 * b;
            if (tot2 > n) break;
            rep(c, b) {
                int s3 = s2 + c;
                int tot3 = tot2 + s3 * c;
                if (tot3 > n) break;
                rep(d, c) {
                    int s4 = s3 + d;
                    int tot4 = tot3 + s4 * d;
                    if (tot4 > n) break;
                    hist[tot4] += 24;
                }
            }
        }
    }
    const int perm[] = {1, 1, 2, 6, 24};
    for(int bit = 1; bit < 8; bit++) {
        rep(a, m + 1) {
            for(int b = bit & 1 ? a : 0; b < (bit & 1 ? a + 1 : a); ++b) {
                int tot2 = a * a + a * b + b * b;
                if (tot2 > n) break;
                for(int c = bit & 2 ? b : 0; c < (bit & 2 ? b + 1 : b); ++c) {
                    int tot3 = tot2 + (a + b + c) * c;
                    if (tot3 > n) break;
                    for(int d = bit & 4 ? c : 0; d < (bit & 4 ? c + 1 : c); ++d) {
                        int tot4 = tot3 + (a + b + c + d) * d;
                        if (tot4 > n) break;
                        int dup = 1;
                        int i = 0;
                        for(int j = 0; j < 4; ++j) if ((bit >> j & 1) == 0) {
                            int len = j - i + 1;
                            dup *= perm[len];
                            i = j + 1;
                        }
                        hist[tot4] += 24 / dup;
                    }
                }
            }
        }
    }
    rep(i, n + 1) cout << hist[i] << '\n';
}
0