結果
問題 | No.2510 Six Cube Sum Counting |
ユーザー |
![]() |
提出日時 | 2024-06-20 10:02:47 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,354 bytes |
コンパイル時間 | 797 ms |
コンパイル使用メモリ | 74,916 KB |
最終ジャッジ日時 | 2025-02-21 23:28:31 |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | TLE * 1 -- * 3 |
other | -- * 26 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:31:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 31 | scanf("%d", &x); | ~~~~~^~~~~~~~~~
ソースコード
/* -*- coding: utf-8 -*- * * 2510.cc: No.2510 Six Cube Sum Counting - yukicoder */ #include<cstdio> #include<map> #include<bitset> #include<algorithm> using namespace std; /* constant */ const int MAX_A = 300; const int BN = 9 * 10; /* typedef */ using btst = bitset<BN>; using mibt = map<int,btst>; /* global variables */ /* subroutines */ /* main */ int main() { int x; scanf("%d", &x); btst msk((1ULL << 9) - 1); mibt scs; for (int a = 0; a <= MAX_A; a++) { int a3 = a * a * a; for (int b = a; b <= MAX_A; b++) { int b3 = b * b * b; for (int c = b; c <= MAX_A; c++) { int s = a3 + b3 + c * c * c; auto mit = scs.find(s); if (mit == scs.end()) { btst bt = ~msk | btst(c); scs[s] = bt; } else { mit->second = (mit->second << 9) | btst(c); } } } } int cnt = 0; for (int d = 0; d <= MAX_A; d++) { int d3 = d * d * d; for (int e = d; e <= MAX_A; e++) { int e3 = e * e * e; for (int f = e; f <= MAX_A; f++) { int s = d3 + e3 + f * f * f; if (s <= x) { auto mit = scs.find(x - s); if (mit != scs.end()) { btst bt = mit->second; for (;;) { btst bi = bt & msk; if (bi == msk) break; int c = bi.to_ulong(); if (c <= d) cnt++; bt >>= 9; } } } } } } printf("%d\n", cnt); return 0; }