結果

問題 No.2510 Six Cube Sum Counting
ユーザー umimelumimel
提出日時 2023-10-21 10:07:20
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,416 bytes
コンパイル時間 1,992 ms
コンパイル使用メモリ 179,892 KB
実行使用メモリ 351,104 KB
最終ジャッジ日時 2023-10-21 10:07:59
合計ジャッジ時間 7,564 ms
ジャッジサーバーID
(参考情報)
judge10 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
4,372 KB
testcase_01 AC 10 ms
4,348 KB
testcase_02 AC 3,986 ms
342,488 KB
testcase_03 AC 9 ms
4,372 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 1,736 ms
186,088 KB
testcase_07 WA -
testcase_08 AC 699 ms
89,336 KB
testcase_09 AC 7 ms
4,372 KB
testcase_10 AC 14 ms
6,248 KB
testcase_11 AC 25 ms
9,516 KB
testcase_12 AC 30 ms
10,832 KB
testcase_13 AC 11 ms
5,144 KB
testcase_14 AC 24 ms
8,736 KB
testcase_15 AC 9 ms
4,372 KB
testcase_16 AC 9 ms
4,372 KB
testcase_17 AC 25 ms
4,372 KB
testcase_18 AC 13 ms
4,372 KB
testcase_19 AC 6 ms
4,372 KB
testcase_20 AC 2,145 ms
220,944 KB
testcase_21 TLE -
testcase_22 AC 3,426 ms
322,576 KB
testcase_23 AC 2,828 ms
264,232 KB
testcase_24 TLE -
testcase_25 AC 50 ms
14,896 KB
testcase_26 TLE -
testcase_27 AC 3,970 ms
346,624 KB
testcase_28 AC 8 ms
4,396 KB
testcase_29 AC 3,689 ms
346,340 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
#define drep(i, cc, n) for (ll i = (cc); i <= (n); ++i)
#define rep(i, n) drep(i, 0, n - 1)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define fi first
#define se second
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());
const ll MOD1000000007 = 1000000007;
const ll MOD998244353 = 998244353;
const ll MOD[3] = {999727999, 1070777777, 1000000007};
const ll LINF = 1LL << 60LL;
const int IINF = (1 << 30) - 1;


void solve(){
    int x; cin >> x;
    unordered_map<int, vector<short>> mp1, mp2;
    int MAX = 300*300*300*3;
    for(int a=0; a<=300; a++) for(int b=a; b<=300; b++) for(int c=b; c<=300; c++){
        int abc = a*a*a+b*b*b+c*c*c;
        if(abc+MAX < x) continue;
        
        if(abc<=x/2){
            mp1[a*a*a+b*b*b+c*c*c].pb((short)c);
        }else if(abc<=x){
            mp2[a*a*a+b*b*b+c*c*c].pb((short)a);
        }
    }
    ll ans = 0;
    for(auto itr=mp1.begin(); itr!=mp1.end(); itr++){
        int y = x-(*itr).fi;
        if(mp2.find(y)==mp2.end()) continue;
        for(short c : (*itr).se){
            ans += (ll)mp2[y].size() - (ll)(lower_bound(all(mp2[y]), c)-mp2[y].begin());
        }
    }

    cout << ans << endl;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int T=1;
    //cin >> T;
    while(T--) solve();
}
0