結果

問題 No.1318 ABCD quadruplets
ユーザー ransewhaleransewhale
提出日時 2020-12-17 01:01:27
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 499 ms / 2,000 ms
コード長 1,210 bytes
コンパイル時間 830 ms
コンパイル使用メモリ 78,316 KB
実行使用メモリ 4,900 KB
最終ジャッジ日時 2023-10-20 10:12:38
合計ジャッジ時間 7,638 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 25 ms
4,348 KB
testcase_14 AC 257 ms
4,712 KB
testcase_15 AC 24 ms
4,348 KB
testcase_16 AC 257 ms
4,516 KB
testcase_17 AC 140 ms
4,348 KB
testcase_18 AC 235 ms
4,608 KB
testcase_19 AC 208 ms
4,756 KB
testcase_20 AC 24 ms
4,348 KB
testcase_21 AC 56 ms
4,348 KB
testcase_22 AC 205 ms
4,348 KB
testcase_23 AC 481 ms
4,900 KB
testcase_24 AC 460 ms
4,900 KB
testcase_25 AC 243 ms
4,900 KB
testcase_26 AC 222 ms
4,596 KB
testcase_27 AC 384 ms
4,900 KB
testcase_28 AC 251 ms
4,900 KB
testcase_29 AC 265 ms
4,900 KB
testcase_30 AC 483 ms
4,900 KB
testcase_31 AC 251 ms
4,900 KB
testcase_32 AC 499 ms
4,900 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

ll ans[161616];

ll f(ll a, ll b, ll c, ll d){
	return ((a*a+b*b+c*c+d*d+(a+b+c+d)*(a+b+c+d))/2);
}

ll calc(ll a, ll b, ll c, ll d){
	ll ret = 24ll;
	if(a==b){
		ret /= 2;
		if(b==c){
			ret /= 3;
			if(c==d){
				ret /= 4;
			}
		}else if(c==d){
			ret /= 2;
		}
	}else if(b==c){
		ret /= 2;
		if(c==d){
			ret /= 3;
		}
	}else if(c==d){
		ret /= 2;
	}
	return ret;
}

int main(void){
	ll n,m,a,b,c,d,i;
	std::cin >> n >> m;
	for(a=0; a<=m; ++a){
		if(f(a,a,a,a)>n){
			break;
		}
		for(b=a; b<=m; ++b){
			if(f(a,b,b,b)>n){
				break;
			}
			for(c=b; c<=m; ++c){
				if(f(a,b,c,c)>n){
					break;
				}
				for(d=c; d<=m; ++d){
					if(f(a,b,c,d)>n){
						break;
					}
					ans[f(a,b,c,d)] += calc(a,b,c,d);
				}
			}
		}
	}
	for(i=0; i<=n; ++i){
		std::cout << ans[i] << std::endl;
	}
	return 0;
}
0