結果

問題 No.2510 Six Cube Sum Counting
ユーザー 👑 kmjpkmjp
提出日時 2023-10-20 23:12:14
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2,082 ms / 4,000 ms
コード長 1,315 bytes
コンパイル時間 2,612 ms
コンパイル使用メモリ 209,612 KB
実行使用メモリ 82,716 KB
最終ジャッジ日時 2023-10-20 23:12:40
合計ジャッジ時間 22,019 ms
ジャッジサーバーID
(参考情報)
judge9 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
4,348 KB
testcase_01 AC 141 ms
4,348 KB
testcase_02 AC 1,742 ms
54,092 KB
testcase_03 AC 181 ms
4,348 KB
testcase_04 AC 76 ms
4,348 KB
testcase_05 AC 75 ms
4,348 KB
testcase_06 AC 323 ms
8,160 KB
testcase_07 AC 70 ms
4,348 KB
testcase_08 AC 219 ms
5,652 KB
testcase_09 AC 145 ms
4,348 KB
testcase_10 AC 190 ms
4,348 KB
testcase_11 AC 162 ms
4,348 KB
testcase_12 AC 175 ms
4,348 KB
testcase_13 AC 187 ms
4,348 KB
testcase_14 AC 155 ms
4,348 KB
testcase_15 AC 146 ms
4,348 KB
testcase_16 AC 159 ms
4,348 KB
testcase_17 AC 36 ms
4,348 KB
testcase_18 AC 30 ms
4,348 KB
testcase_19 AC 30 ms
4,348 KB
testcase_20 AC 1,701 ms
53,300 KB
testcase_21 AC 1,572 ms
51,188 KB
testcase_22 AC 2,082 ms
82,716 KB
testcase_23 AC 2,029 ms
59,372 KB
testcase_24 AC 1,853 ms
56,468 KB
testcase_25 AC 207 ms
4,348 KB
testcase_26 AC 850 ms
16,516 KB
testcase_27 AC 1,494 ms
47,756 KB
testcase_28 AC 181 ms
4,348 KB
testcase_29 AC 1,945 ms
82,716 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
template<class T> bool chmax(T &a, const T &b) { if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;}
//-------------------------------------------------------

ll X;
unordered_map<int,int> C;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>X;
	int a,b,c,d,e,f;
	for(d=0;d<=300;d++) {
		for(e=d;e<=300;e++) for(f=e;f<=300;f++) {
			int v=d*d*d+e*e*e+f*f*f;
			if(v*2>=X&&v<=X) C[v]++;
		}
	}
	ll ret=0;
	for(c=0;c<=300;c++) {
		for(b=c;b>=0;b--) for(a=b;a>=0;a--) {
			if(C.count(X-c*c*c-b*b*b-a*a*a)) ret+=C[X-c*c*c-b*b*b-a*a*a];
		}
		d=c;
		for(e=d;e<=300;e++) for(f=e;f<=300;f++) {
			int v=d*d*d+e*e*e+f*f*f;
			if(v*2>=X&&v<=X) C[v]--;
		}
	}
	cout<<ret<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}
0