結果

問題 No.1318 ABCD quadruplets
ユーザー tkmst201tkmst201
提出日時 2020-12-19 16:38:06
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 395 ms / 2,000 ms
コード長 2,119 bytes
コンパイル時間 1,842 ms
コンパイル使用メモリ 204,776 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-21 09:19:59
合計ジャッジ時間 5,910 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 1 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 1 ms
4,348 KB
testcase_10 AC 1 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 8 ms
4,348 KB
testcase_14 AC 86 ms
4,348 KB
testcase_15 AC 4 ms
4,348 KB
testcase_16 AC 197 ms
4,348 KB
testcase_17 AC 11 ms
4,348 KB
testcase_18 AC 76 ms
4,348 KB
testcase_19 AC 32 ms
4,348 KB
testcase_20 AC 7 ms
4,348 KB
testcase_21 AC 20 ms
4,348 KB
testcase_22 AC 15 ms
4,348 KB
testcase_23 AC 373 ms
4,348 KB
testcase_24 AC 259 ms
4,348 KB
testcase_25 AC 48 ms
4,348 KB
testcase_26 AC 28 ms
4,348 KB
testcase_27 AC 157 ms
4,348 KB
testcase_28 AC 53 ms
4,348 KB
testcase_29 AC 69 ms
4,348 KB
testcase_30 AC 392 ms
4,348 KB
testcase_31 AC 49 ms
4,348 KB
testcase_32 AC 395 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 + 1, M + 1) {
		if ((i + j + j + j) * (i + j + j + j) + i * i + 3 * j * j > 2 * N) break;
		FOR(k, j + 1, M + 1) {
			if ((i + j + k + k) * (i + j + k + k) + i * i + j * j + 2 * k * k > 2 * N) break;
			FOR(l, k + 1, 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) ans[s >> 1] += 24;
			}
		}
	}
	
	REP(i, M + 1) FOR(j, i + 1, M + 1) FOR(k, j + 1, M + 1) {
		{
			const int s = (i + i + j + k) * (i + i + j + k) + 2 * i * i + j * j + k * k;
			if (~s & 1 && s <= 2 * N) ans[s >> 1] += 12;
		}
		{
			const int s = (i + j + j + k) * (i + j + j + k) + 2 * j * j + i * i + k * k;
			if (~s & 1 && s <= 2 * N) ans[s >> 1] += 12;
		}
		{
			const int s = (i + j + k + k) * (i + j + k + k) + 2 * k * k + i * i + j * j;
			if (~s & 1 && s <= 2 * N) ans[s >> 1] += 12;
		}
	}
	
	REP(i, M + 1) FOR(j, i + 1, M + 1) {
		{
			const int s = (i + i + j + j) * (i + i + j + j) + 2 * (i * i + j * j);
			if (~s & 1 && s <= 2 * N) ans[s >> 1] += 6;
		}
		{
			const int s = (i + i + i + j) * (i + i + i + j) + 3 * i * i + j * j;
			if (~s & 1 && s <= 2 * N) ans[s >> 1] += 4;
		}
		{
			const int s = (i + j + j + j) * (i + j + j + j) + 3 * j * j + i * i;
			if (~s & 1 && s <= 2 * N) ans[s >> 1] += 4;
		}
	}
	
	REP(i, M + 1) {
		const int s = 16 * i * i + 4 * i * i;
		if (~s & 1 && s <= 2 * N) ++ans[s >> 1];
	}
	
	
	
	REP(i, N + 1) printf("%d\n", ans[i]);
}
0