結果

問題 No.1318 ABCD quadruplets
ユーザー tkmst201tkmst201
提出日時 2020-12-19 16:47:26
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 758 ms / 2,000 ms
コード長 1,360 bytes
コンパイル時間 2,147 ms
コンパイル使用メモリ 203,360 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-21 09:21:11
合計ジャッジ時間 8,561 ms
ジャッジサーバーID
(参考情報)
judge9 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 2 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 11 ms
4,348 KB
testcase_14 AC 222 ms
4,348 KB
testcase_15 AC 5 ms
4,348 KB
testcase_16 AC 365 ms
4,348 KB
testcase_17 AC 15 ms
4,348 KB
testcase_18 AC 196 ms
4,348 KB
testcase_19 AC 75 ms
4,348 KB
testcase_20 AC 10 ms
4,348 KB
testcase_21 AC 38 ms
4,348 KB
testcase_22 AC 16 ms
4,348 KB
testcase_23 AC 716 ms
4,348 KB
testcase_24 AC 584 ms
4,348 KB
testcase_25 AC 111 ms
4,348 KB
testcase_26 AC 57 ms
4,348 KB
testcase_27 AC 398 ms
4,348 KB
testcase_28 AC 131 ms
4,348 KB
testcase_29 AC 167 ms
4,348 KB
testcase_30 AC 748 ms
4,348 KB
testcase_31 AC 120 ms
4,348 KB
testcase_32 AC 758 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
template<typename A, typename B> inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; }
template<typename A, typename B> inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = false;
//---------------------------------//

int main() {
	int N, M;
	cin >> N >> M;
	
	vector<int> ans(N + 1);
	REP(i, M + 1) FOR(j, i, M + 1) {
		if ((i + j + j + j) * (i + j + j + j) + i * i + 3 * j * j > 2 * N) break;
		FOR(k, j, M + 1) {
			if ((i + j + k + k) * (i + j + k + k) + i * i + j * j + 2 * k * k > 2 * N) break;
			FOR(l, k, M + 1) {
				const int s = (i + j + k + l) * (i + j + k + l) + i * i + j * j + k * k + l * l;
				if (~s & 1 && s <= 2 * N) {
					int eq = (i == j) + (j == k) + (k == l);
					if (i == l) ans[s >> 1] += 1;
					else if (i == k || j == l) ans[s >> 1] += 4;
					else if (i == j && k == l) ans[s >> 1] += 6;
					else if (i == j || j == k || k == l) ans[s >> 1] += 12;
					else ans[s >> 1] += 24;
				}
			}
		}
	}
	
	REP(i, N + 1) printf("%d\n", ans[i]);
}
0