結果
問題 |
No.2510 Six Cube Sum Counting
|
ユーザー |
|
提出日時 | 2023-10-20 23:39:04 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 1,077 ms / 4,000 ms |
コード長 | 795 bytes |
コンパイル時間 | 2,973 ms |
コンパイル使用メモリ | 227,288 KB |
最終ジャッジ日時 | 2025-02-17 11:18:50 |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 26 |
ソースコード
#include<bits/stdc++.h> #include<ext/pb_ds/hash_policy.hpp> #include<ext/pb_ds/assoc_container.hpp> using namespace std; using ll=long long; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); time_t c=clock(); int X; __gnu_pbds::gp_hash_table<int,int>cntA,cntB; cin>>X; vector C(301,vector(0,0)),D(301,vector(0,0)); for(int i=0;i<=300;i++){ for(int j=i;j<=300;j++){ for(int k=j;k<=300;k++){ int t=i*i*i+j*j*j+k*k*k; C[k].push_back(t); D[i].push_back(t); } } } for(int i=0;i<=300;i++){ for(int j:C[i]){ cntB[j]+=1; } } int ans=0; for(int i=0;i<=300;i++){ for(int j:C[i]){ if(cntB.find(X-j)!=cntB.end())ans+=cntB[X-j]; } for(int j:D[i]){ cntB[j]-=1; } } cout<<ans<<'\n'; }