結果
| 問題 |
No.1318 ABCD quadruplets
|
| コンテスト | |
| ユーザー |
Kude
|
| 提出日時 | 2020-12-15 23:07:25 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 182 ms / 2,000 ms |
| コード長 | 1,862 bytes |
| コンパイル時間 | 2,080 ms |
| コンパイル使用メモリ | 192,196 KB |
| 最終ジャッジ日時 | 2025-01-17 01:15:24 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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;
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';
}
Kude