結果
| 問題 | No.1318 ABCD quadruplets |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-01-05 03:32:01 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 263 ms / 2,000 ms |
| コード長 | 2,172 bytes |
| 記録 | |
| コンパイル時間 | 1,191 ms |
| コンパイル使用メモリ | 131,168 KB |
| 最終ジャッジ日時 | 2025-01-17 09:45:28 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <array>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
using namespace std;
using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;
template<class T>
inline bool chmax(T& x, T y){
if(x < y){
x = y;
return true;
}
return false;
}
template<class T>
inline bool chmin(T& x, T y){
if(x > y){
x = y;
return true;
}
return false;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, m;
cin >> n >> m;
auto calc = [&](int a, int b, int c, int d){
if(a == b){
if(b == c){
if(c == d) return 1;
else return 4;
}
else{
if(c == d) return 6;
else return 12;
}
}
else{
if(b == c){
if(c == d) return 4;
else return 12;
}
else{
if(c == d) return 12;
else return 24;
}
}
};
vector<ll> ans(n + 1);
for(int a = 0; a <= m; ++a){
int s = a * a;
for(int b = a; b <= m && s + (a + b) * b <= n; ++b){
s += (a + b) * b;
for(int c = b; c <= m && s + (a + b + c) * c <= n; ++c){
s += (a + b + c) * c;
for(int d = c; d <= m && s + (a + b + c + d) * d <= n; ++d){
ans[s + (a + b + c + d) * d] += calc(a, b, c, d);
}
s -= (a + b + c) * c;
}
s -= (a + b) * b;
}
}
for(auto x : ans) cout << x << '\n';
return 0;
}