結果

問題 No.1318 ABCD quadruplets
ユーザー trineutrontrineutron
提出日時 2020-12-16 01:05:22
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 318 ms / 2,000 ms
コード長 979 bytes
コンパイル時間 2,259 ms
コンパイル使用メモリ 203,708 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-20 08:26:33
合計ジャッジ時間 6,592 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 1 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 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 117 ms
4,348 KB
testcase_15 AC 4 ms
4,348 KB
testcase_16 AC 155 ms
4,348 KB
testcase_17 AC 14 ms
4,348 KB
testcase_18 AC 104 ms
4,348 KB
testcase_19 AC 46 ms
4,348 KB
testcase_20 AC 7 ms
4,348 KB
testcase_21 AC 20 ms
4,348 KB
testcase_22 AC 17 ms
4,348 KB
testcase_23 AC 317 ms
4,348 KB
testcase_24 AC 292 ms
4,348 KB
testcase_25 AC 64 ms
4,348 KB
testcase_26 AC 38 ms
4,348 KB
testcase_27 AC 203 ms
4,348 KB
testcase_28 AC 74 ms
4,348 KB
testcase_29 AC 92 ms
4,348 KB
testcase_30 AC 317 ms
4,348 KB
testcase_31 AC 69 ms
4,348 KB
testcase_32 AC 318 ms
4,348 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int count(int, int, int, int)':
main.cpp:21:1: warning: control reaches end of non-void function [-Wreturn-type]
   21 | }
      | ^

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int f(int a, int b, int c, int d) {
    int s = a + b + c + d;
    return (s * s + a * a + b * b + c * c + d * d) / 2;
}

int count(int a, int b, int c, int d) {
    int same = (a == b) + (b == c) + (c == d);
    switch(same) {
    case 0:
        return 24;
    case 1:
        return 12;
    case 2:
        return b == c ? 4 : 6;
    case 3:
        return 1;
    }
}

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> ans(n + 1);
    for (int a = 0; a <= m; a++) {
        for (int b = a; b <= m; b++) {
            if (f(a, b, 0, 0) > n) break;
            for (int c = b; c <= m; c++) {
                if (f(a, b, c, 0) > n) break;
                for (int d = c; d <= m; d++) {
                    if (f(a, b, c, d) > n) break;
                    ans[f(a, b, c, d)] += count(a, b, c, d);
                }
            }
        }
    }
    for (int i = 0; i <= n; i++) {
        cout << ans[i] << "\n";
    }
}
0