結果
問題 | No.937 Ultra Sword |
ユーザー | vwxyz |
提出日時 | 2023-11-29 19:35:29 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,618 bytes |
コンパイル時間 | 290 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 112,000 KB |
最終ジャッジ日時 | 2024-09-26 13:36:00 |
合計ジャッジ時間 | 20,623 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 165 ms
89,600 KB |
testcase_01 | WA | - |
testcase_02 | AC | 186 ms
89,344 KB |
testcase_03 | AC | 184 ms
89,600 KB |
testcase_04 | AC | 190 ms
89,984 KB |
testcase_05 | AC | 434 ms
110,720 KB |
testcase_06 | AC | 664 ms
108,672 KB |
testcase_07 | AC | 664 ms
110,208 KB |
testcase_08 | AC | 658 ms
102,272 KB |
testcase_09 | AC | 651 ms
100,608 KB |
testcase_10 | AC | 662 ms
112,000 KB |
testcase_11 | AC | 253 ms
90,496 KB |
testcase_12 | AC | 267 ms
103,040 KB |
testcase_13 | AC | 268 ms
103,168 KB |
testcase_14 | AC | 261 ms
104,448 KB |
testcase_15 | AC | 263 ms
100,608 KB |
testcase_16 | AC | 260 ms
90,496 KB |
testcase_17 | AC | 253 ms
90,752 KB |
testcase_18 | AC | 265 ms
101,632 KB |
testcase_19 | AC | 256 ms
95,616 KB |
testcase_20 | AC | 257 ms
94,080 KB |
testcase_21 | AC | 549 ms
110,976 KB |
testcase_22 | AC | 180 ms
89,600 KB |
testcase_23 | AC | 179 ms
89,472 KB |
testcase_24 | AC | 481 ms
111,872 KB |
testcase_25 | AC | 437 ms
108,416 KB |
testcase_26 | AC | 422 ms
105,344 KB |
testcase_27 | AC | 422 ms
105,472 KB |
testcase_28 | AC | 435 ms
106,624 KB |
testcase_29 | AC | 409 ms
96,896 KB |
testcase_30 | AC | 429 ms
103,168 KB |
testcase_31 | AC | 427 ms
109,952 KB |
testcase_32 | AC | 422 ms
103,296 KB |
testcase_33 | AC | 436 ms
110,080 KB |
testcase_34 | AC | 421 ms
97,536 KB |
testcase_35 | AC | 410 ms
96,768 KB |
testcase_36 | AC | 452 ms
108,416 KB |
testcase_37 | AC | 425 ms
97,792 KB |
testcase_38 | AC | 439 ms
105,344 KB |
testcase_39 | AC | 419 ms
97,408 KB |
testcase_40 | AC | 431 ms
106,752 KB |
testcase_41 | AC | 398 ms
99,200 KB |
testcase_42 | AC | 429 ms
104,064 KB |
testcase_43 | AC | 414 ms
103,040 KB |
testcase_44 | AC | 470 ms
97,536 KB |
testcase_45 | AC | 412 ms
99,584 KB |
testcase_46 | AC | 437 ms
100,608 KB |
ソースコード
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) le=max_A.bit_length() poly=[0]*(1<<le) poly[0]=1 for a in A: while a<1<<le: poly[a]=1 a*=2 mod=(1<<61)-1 poly=Hadamard(poly,le,mod=mod) for i in range(1<<le): poly[i]=pow(poly[i],10**9,mod) poly=Hadamard(poly,le,mod=mod,inverse=True) 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)