結果

問題 No.2510 Six Cube Sum Counting
ユーザー otoshigootoshigo
提出日時 2023-10-20 22:45:31
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 1,480 bytes
コンパイル時間 1,141 ms
コンパイル使用メモリ 103,256 KB
実行使用メモリ 514,892 KB
最終ジャッジ日時 2023-10-20 22:45:44
合計ジャッジ時間 11,612 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 MLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
#include<unordered_map>
#include<atcoder/modint>
using namespace std;
using namespace atcoder;
using ll=long long;
using mint=modint998244353;
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
template<class T> bool chmax(T &a, T b){if (a < b){a = b;return true;} else return false;}
template<class T> bool chmin(T &a, T b){if (a > b){a = b;return true;} else return false;}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll X;
    cin>>X;
    ll S=0;
    ll ans=0;
    vector<int>vec;
    for(int x=0;x<=300;x++)for(int y=x;y<=300;y++)for(int z=y;z<=300;z++){
        vec.push_back(x*x*x+y*y*y+z*z*z);
    }
    sort(all(vec));
    vec.erase(unique(all(vec)),vec.end());
    int L=vec.size();
    unordered_map<int,int>mp;
    for(int i=0;i<L;i++)mp[vec[i]]=i;
    vector<vector<int>>V(L),W(L);
    for(int x=0;x<=300;x++)for(int y=x;y<=300;y++)for(int z=y;z<=300;z++){
        V[mp[x*x*x+y*y*y+z*z*z]].push_back(x);
    }
    for(int a=0;S<=X&&a<=300;a++){
        S+=a*a*a;
        for(int b=a;S+b*b*b<=X&&b<=300;b++){
            S+=b*b*b;
            for(int c=b;S+c*c*c<=X&&c<=300;c++){
                S+=c*c*c;
                if(mp.count(X-S)){
                int d=mp[X-S];
                ans+=V[d].end()-lower_bound(all(V[d]),c);
                }
                S-=c*c*c;
            }
            S-=b*b*b;
        }
        S-=a*a*a;
    }
    cout<<ans<<"\n";
}
0