結果
問題 |
No.1318 ABCD quadruplets
|
ユーザー |
![]() |
提出日時 | 2020-12-15 23:08:09 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 804 ms / 2,000 ms |
コード長 | 1,323 bytes |
コンパイル時間 | 1,596 ms |
コンパイル使用メモリ | 192,052 KB |
最終ジャッジ日時 | 2025-01-17 01:15:39 |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 |
ソースコード
#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; const int perm[] = {1, 1, 2, 6, 24}; for(int bit = 0; 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'; }