結果
問題 | No.1318 ABCD quadruplets |
ユーザー | t33f |
提出日時 | 2020-12-16 19:27:06 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 569 ms / 2,000 ms |
コード長 | 1,095 bytes |
コンパイル時間 | 812 ms |
コンパイル使用メモリ | 83,808 KB |
最終ジャッジ日時 | 2025-01-17 02:04:44 |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 |
ソースコード
#include <iostream> #include <cstring> #include <cstdio> #include <algorithm> #include <cassert> #include <unordered_map> #include <vector> using namespace std; int calc(int a, int b, int c, int d) { int s = d, r = 0; r += d * s; s += c; r += c * s; s += b; r += b * s; s += a; r += a * s; return r; } int calc_perm_count(int a, int b, int c, int d) { if (a == d) return 1; if (a == c || b == d) return 4; if (a == b && c == d) return 6; if (a == b || b == c || c == d) return 12; return 24; } vector<int> solve(int n, int m) { vector<int> ans(n+1, 0); for (int a = 0; a <= m; a++) { for (int b = a; b <= m; b++) { for (int c = b; c <= m; c++) { for (int d = c; d <= m; d++) { if (int v = calc(a, b, c, d); v > n) break; else ans[v] += calc_perm_count(a, b, c, d); } } } } return ans; } int main() { int n, m; cin >> n >> m; vector<int> ans = solve(n, m); for (int x : ans) printf("%d\n", x); }