結果

問題 No.376 立方体のN等分 (2)
ユーザー mkawa2mkawa2
提出日時 2020-03-26 13:08:47
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 1,107 bytes
コンパイル時間 428 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2025-01-02 01:19:03
合計ジャッジ時間 76,829 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 33 WA * 3 TLE * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10 ** 6)
from bisect import *
from collections import *
from heapq import *

def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def SI(): return sys.stdin.readline()[:-1]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
int1 = lambda x: int(x) - 1
def MI1(): return map(int1, sys.stdin.readline().split())
def LI1(): return list(map(int1, sys.stdin.readline().split()))
p2D = lambda x: print(*x, sep="\n")
dij = [(1, 0), (0, 1), (-1, 0), (0, -1)]

def main():
    def fac(n):
        res=[]
        for d in range(1,n+1):
            if d**2>n:break
            if n%d==0:res.append(d)
        return res

    def cal(m):
        f=ff[m]
        n1=n//f
        for d in range(int(n1**0.5)+1,0,-1):
            if n1%d==0:return d+n1//d+f-3

    n=II()
    ff=fac(n)
    fn=len(ff)
    l=-1
    r=fn
    while l+2<r:
        m1=(l*2+r)//3
        m2=(l+r*2)//3
        if cal(m1)<cal(m2):r=m2
        else:l=m1
    print(cal((l+r)//2),n-1)

main()
0