結果

問題 No.2510 Six Cube Sum Counting
ユーザー tnakao0123
提出日時 2024-06-20 10:53:44
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 3,039 ms / 4,000 ms
コード長 1,185 bytes
コンパイル時間 2,060 ms
コンパイル使用メモリ 90,532 KB
最終ジャッジ日時 2025-02-21 23:30:21
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

/* -*- coding: utf-8 -*-
*
* 2510.cc: No.2510 Six Cube Sum Counting - yukicoder
*/
#include<cstdio>
#include<map>
#include<unordered_map>
#include<algorithm>
using namespace std;
/* constant */
const int MAX_A = 300;
const int BN = 9 * 10;
/* typedef */
using mii = map<int,__int128>;
using umii = unordered_map<int,__int128>;
/* global variables */
/* subroutines */
/* main */
int main() {
int x;
scanf("%d", &x);
__int128 msk = (1 << 9) - 1;
umii scs;
int cnt = 0;
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;
if (s * 2 <= x) {
auto mit = scs.find(s);
if (mit == scs.end()) {
__int128 bt = ~msk | c;
scs[s] = bt;
}
else {
mit->second = (mit->second << 9) | c;
}
}
if (x >= s && s * 2 >= x) {
auto mit = scs.find(x - s);
if (mit != scs.end()) {
__int128 bt = mit->second;
for (;;) {
int c = bt & msk;
if (c == msk) break;
if (c <= a) cnt++;
bt >>= 9;
}
}
}
}
}
}
printf("%d\n", cnt);
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0