結果

問題 No.2510 Six Cube Sum Counting
ユーザー navel_tosnavel_tos
提出日時 2023-10-20 23:19:25
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,859 bytes
コンパイル時間 437 ms
コンパイル使用メモリ 81,788 KB
実行使用メモリ 462,720 KB
最終ジャッジ日時 2023-10-20 23:20:23
合計ジャッジ時間 11,137 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
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 #

#yukicoder409C

#愚直だと余裕を持ってTLE
def simple():
    X=int(input()); L=[pow(i,3) for i in range(301)]; ans=0
    for a in range(301):
        if L[a]*6>=X: break
        cnt=L[a]
        for b in range(a,301):
            if cnt+L[b]*5>=X: break
            cnt=L[a]+L[b]
            for c in range(b,301):
                if cnt+L[c]*4>=X: break
                cnt=L[a]+L[b]+L[c]
                for d in range(c,301):
                    if cnt+L[d]*3>=X: break
                    cnt=L[a]+L[b]+L[c]+L[d]
                    for e in range(d,301):
                        if cnt+L[e]*2>=X: break
                        cnt=L[a]+L[b]+L[c]+L[d]+L[e]
                        for f in range(e,301):
                            if   cnt+L[f]==X: ans+=1
                            elif cnt+L[f] >X: break
    return ans


#方針が立たない。仕方ないので半分全列挙。
from collections import defaultdict as dd

X=int(input()); P=[pow(i,3) for i in range(301)]
g=lambda x,y,z: P[x]+P[y]+P[z]

#cを固定して全列挙を行う
#S: g(-,-,c以下)の値をListに格納  L: g(c以上,-,-)の数をDictに格納
S,L=dd(int),dd(int)

#先にg(d,e,f)の全パターンをLに格納する  引数のfと関数のfが重複するのを避けるため関数をgに
for a in range(301):
    for b in range(a,301):
        for c in range(b,301): L[g(a,b,c)]+=1

#cを固定して全探索
from time import perf_counter as pf
Z=pf()
ans=0
for c in range(301):
    #あり得るパターンを加算
    for a in range(c+1):
        for b in range(a,c+1): S[P[a]+P[b]+P[c]]+=1
    #Sを全探索
    for now in S: ans+=S[now]*L[X-now]
    #終了処理 最小値(d)がcであるパターンをLから除去
    for e in range(c,301):
        for f in range(c,301): L[P[c]+P[e]+P[f]]-=1
    if c%100==0: print(c,pf()-Z)
    














0