結果
問題 | No.937 Ultra Sword |
ユーザー | vwxyz |
提出日時 | 2023-11-29 19:25:09 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 2,503 bytes |
コンパイル時間 | 174 ms |
コンパイル使用メモリ | 12,928 KB |
実行使用メモリ | 51,436 KB |
最終ジャッジ日時 | 2024-09-26 13:34:54 |
合計ジャッジ時間 | 9,373 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 42 ms
17,664 KB |
testcase_01 | TLE | - |
testcase_02 | AC | 42 ms
11,904 KB |
testcase_03 | AC | 43 ms
11,904 KB |
testcase_04 | AC | 45 ms
11,904 KB |
testcase_05 | TLE | - |
testcase_06 | TLE | - |
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 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
testcase_36 | -- | - |
testcase_37 | -- | - |
testcase_38 | -- | - |
testcase_39 | -- | - |
testcase_40 | -- | - |
testcase_41 | -- | - |
testcase_42 | -- | - |
testcase_43 | -- | - |
testcase_44 | -- | - |
testcase_45 | -- | - |
testcase_46 | -- | - |
ソースコード
import bisect import copy import decimal import fractions import heapq import itertools import math import random import sys import time from collections import Counter,deque,defaultdict from functools import lru_cache,reduce from heapq import heappush,heappop,heapify,heappushpop,_heappop_max,_heapify_max def _heappush_max(heap,item): heap.append(item) heapq._siftdown_max(heap, 0, len(heap)-1) def _heappushpop_max(heap, item): if heap and item < heap[0]: item, heap[0] = heap[0], item heapq._siftup_max(heap, 0) return item from math import gcd as GCD read=sys.stdin.read readline=sys.stdin.readline readlines=sys.stdin.readlines write=sys.stdout.write #import pypyjit #pypyjit.set_param('max_unroll_recursion=-1') #sys.set_int_max_str_digits(10**9) def Hadamard(polynomial,n,mod=0,inverse=False): assert mod%2 polynomial_=[x for x in polynomial]+[0]*((1<<n)-len(polynomial)) for bit in range(n): for i in range(1<<n): ii=i^(1<<bit) if i>ii: continue polynomial_[i],polynomial_[ii]=polynomial_[i]+polynomial_[ii],polynomial_[i]-polynomial_[ii] if mod: polynomial_[i]%=mod polynomial_[ii]%=mod if inverse: if mod: inve_2=pow((mod+1)//2,n) for i in range(1<<n): polynomial_[i]*=inve_2 polynomial_[i]%=mod else: pow_2=pow(2,n) for i in range(1<<n): polynomial_[i]/=pow_2 return polynomial_ def XOR_Convolution(polynomial0,polynomial1,mod=0): n=(max(len(polynomial0),len(polynomial1))-1).bit_length() Hadamard_polynomial0=Hadamard(polynomial0,n,mod=mod) Hadamard_polynomial1=Hadamard(polynomial1,n,mod=mod) if mod: convolution=[x*y%mod for x,y in zip(Hadamard_polynomial0,Hadamard_polynomial1)] else: convolution=[x*y for x,y in zip(Hadamard_polynomial0,Hadamard_polynomial1)] convolution=Hadamard(convolution,n,mod=mod,inverse=True) return convolution N=int(readline()) A=list(map(int,readline().split())) max_A=max(A) poly=[0]*(2*max_A+1) poly[0]=1 for a in A: while a<=max_A*2: poly[a]+=1 a*=2 poly=XOR_Convolution(poly,poly,mod=(1<<61)-1) C=[0]*(max_A+1) for a in A: C[a]+=1 sum_A=sum(A) ans=sum_A for i in range(1,max_A+1): if poly[i]==0: continue s=sum_A for j in range(i,max_A+1,i): s-=C[j]*(j-j//i) ans=min(ans,s) print(ans)