結果
問題 | No.1318 ABCD quadruplets |
ユーザー |
![]() |
提出日時 | 2020-12-19 16:47:26 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 800 ms / 2,000 ms |
コード長 | 1,360 bytes |
コンパイル時間 | 2,084 ms |
コンパイル使用メモリ | 193,392 KB |
最終ジャッジ日時 | 2025-01-17 03:54:11 |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 |
ソースコード
#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]); }