結果
| 問題 |
No.2510 Six Cube Sum Counting
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-10-20 22:27:58 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2,672 ms / 4,000 ms |
| コード長 | 1,639 bytes |
| コンパイル時間 | 3,115 ms |
| コンパイル使用メモリ | 269,344 KB |
| 実行使用メモリ | 45,696 KB |
| 最終ジャッジ日時 | 2024-09-20 20:07:04 |
| 合計ジャッジ時間 | 63,493 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 26 |
ソースコード
#include <bits/stdc++.h>
// #include <x86intrin.h>
using namespace std;
using namespace numbers;
int main(){
cin.tie(0)->sync_with_stdio(0);
cin.exceptions(ios::badbit | ios::failbit);
vector<vector<int>> left(301), right(301);
for(auto x = 0; x <= 300; ++ x){
for(auto y = x; y <= 300; ++ y){
for(auto z = y; z <= 300; ++ z){
left[z].push_back(x * x * x + y * y * y + z * z * z);
right[x].push_back(x * x * x + y * y * y + z * z * z);
}
}
}
for(auto x = 0; x <= 300; ++ x){
ranges::sort(left[x]);
ranges::sort(right[x] | ranges::views::reverse);
}
int obj;
cin >> obj;
int res = 0;
for(auto c = 0; c <= 300; ++ c){
for(auto d = c; d <= 300; ++ d){
for(auto cl = 0, dl = 0; cl < (int)left[c].size() && left[c][cl] <= obj / 2; ){
int cr = cl;
while(cr < (int)left[c].size() && left[c][cl] == left[c][cr]){
++ cr;
}
int rem = obj - left[c][cl];
while(dl < (int)right[d].size() && right[d][dl] > rem){
++ dl;
}
int dr = dl;
while(dr < (int)right[d].size() && right[d][dr] == rem){
++ dr;
}
res += (cr - cl) * (dr - dl);
cl = cr;
dl = dr;
}
}
}
cout << res << "\n";
return 0;
}
/*
*/
////////////////////////////////////////////////////////////////////////////////////////
// //
// Coded by Aeren //
// //
////////////////////////////////////////////////////////////////////////////////////////