結果
問題 | No.732 3PrimeCounting |
ユーザー | vwxyz |
提出日時 | 2022-10-03 02:57:26 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 2,862 bytes |
コンパイル時間 | 456 ms |
コンパイル使用メモリ | 82,048 KB |
実行使用メモリ | 101,260 KB |
最終ジャッジ日時 | 2024-06-07 19:34:27 |
合計ジャッジ時間 | 31,929 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 45 ms
59,392 KB |
testcase_01 | AC | 43 ms
54,144 KB |
testcase_02 | AC | 43 ms
54,528 KB |
testcase_03 | AC | 43 ms
54,272 KB |
testcase_04 | AC | 44 ms
54,016 KB |
testcase_05 | AC | 44 ms
54,144 KB |
testcase_06 | AC | 43 ms
54,144 KB |
testcase_07 | AC | 42 ms
53,888 KB |
testcase_08 | AC | 42 ms
54,144 KB |
testcase_09 | AC | 42 ms
54,016 KB |
testcase_10 | AC | 44 ms
53,888 KB |
testcase_11 | AC | 44 ms
54,016 KB |
testcase_12 | AC | 43 ms
54,016 KB |
testcase_13 | AC | 44 ms
54,272 KB |
testcase_14 | AC | 44 ms
53,888 KB |
testcase_15 | AC | 45 ms
54,016 KB |
testcase_16 | AC | 43 ms
54,144 KB |
testcase_17 | AC | 42 ms
54,016 KB |
testcase_18 | AC | 45 ms
54,144 KB |
testcase_19 | AC | 45 ms
54,016 KB |
testcase_20 | AC | 56 ms
63,360 KB |
testcase_21 | AC | 73 ms
69,760 KB |
testcase_22 | AC | 72 ms
70,016 KB |
testcase_23 | AC | 51 ms
60,928 KB |
testcase_24 | AC | 49 ms
60,928 KB |
testcase_25 | AC | 89 ms
74,624 KB |
testcase_26 | AC | 81 ms
71,424 KB |
testcase_27 | AC | 62 ms
65,152 KB |
testcase_28 | AC | 61 ms
65,280 KB |
testcase_29 | AC | 74 ms
69,504 KB |
testcase_30 | AC | 71 ms
69,376 KB |
testcase_31 | AC | 75 ms
71,296 KB |
testcase_32 | AC | 82 ms
72,576 KB |
testcase_33 | AC | 78 ms
72,832 KB |
testcase_34 | AC | 82 ms
72,704 KB |
testcase_35 | AC | 76 ms
70,912 KB |
testcase_36 | AC | 75 ms
70,784 KB |
testcase_37 | AC | 55 ms
62,976 KB |
testcase_38 | AC | 56 ms
62,720 KB |
testcase_39 | AC | 80 ms
71,168 KB |
testcase_40 | AC | 75 ms
70,656 KB |
testcase_41 | AC | 74 ms
70,528 KB |
testcase_42 | AC | 75 ms
70,272 KB |
testcase_43 | AC | 71 ms
69,120 KB |
testcase_44 | AC | 69 ms
68,992 KB |
testcase_45 | AC | 62 ms
66,176 KB |
testcase_46 | AC | 61 ms
66,176 KB |
testcase_47 | AC | 67 ms
67,840 KB |
testcase_48 | AC | 94 ms
77,440 KB |
testcase_49 | AC | 93 ms
77,056 KB |
testcase_50 | AC | 76 ms
70,272 KB |
testcase_51 | AC | 75 ms
70,016 KB |
testcase_52 | AC | 62 ms
65,536 KB |
testcase_53 | AC | 134 ms
77,440 KB |
testcase_54 | AC | 2,094 ms
93,808 KB |
testcase_55 | AC | 2,097 ms
93,436 KB |
testcase_56 | AC | 2,044 ms
93,432 KB |
testcase_57 | AC | 338 ms
80,052 KB |
testcase_58 | AC | 333 ms
80,420 KB |
testcase_59 | AC | 160 ms
77,696 KB |
testcase_60 | AC | 499 ms
81,096 KB |
testcase_61 | AC | 489 ms
81,100 KB |
testcase_62 | AC | 2,817 ms
101,260 KB |
testcase_63 | AC | 1,125 ms
84,500 KB |
testcase_64 | AC | 647 ms
81,780 KB |
testcase_65 | AC | 645 ms
82,044 KB |
testcase_66 | AC | 45 ms
54,400 KB |
testcase_67 | AC | 47 ms
54,784 KB |
testcase_68 | AC | 2,326 ms
96,792 KB |
testcase_69 | AC | 1,760 ms
95,832 KB |
testcase_70 | AC | 2,065 ms
93,416 KB |
testcase_71 | AC | 2,004 ms
94,296 KB |
testcase_72 | AC | 985 ms
83,576 KB |
testcase_73 | TLE | - |
testcase_74 | -- | - |
testcase_75 | -- | - |
testcase_76 | -- | - |
testcase_77 | -- | - |
testcase_78 | -- | - |
testcase_79 | -- | - |
testcase_80 | -- | - |
testcase_81 | -- | - |
testcase_82 | -- | - |
testcase_83 | -- | - |
testcase_84 | -- | - |
testcase_85 | -- | - |
testcase_86 | -- | - |
testcase_87 | -- | - |
testcase_88 | -- | - |
ソースコード
from collections import defaultdict class Prime: def __init__(self,N): assert N<=10**8 self.smallest_prime_factor=[None]*(N+1) for i in range(2,N+1,2): self.smallest_prime_factor[i]=2 n=int(N**.5)+1 for p in range(3,n,2): if self.smallest_prime_factor[p]==None: self.smallest_prime_factor[p]=p for i in range(p**2,N+1,2*p): if self.smallest_prime_factor[i]==None: self.smallest_prime_factor[i]=p for p in range(n,N+1): if self.smallest_prime_factor[p]==None: self.smallest_prime_factor[p]=p self.primes=[p for p in range(N+1) if p==self.smallest_prime_factor[p]] def Factorize(self,N): assert N>=1 factors=defaultdict(int) if N<=len(self.smallest_prime_factor)-1: while N!=1: factors[self.smallest_prime_factor[N]]+=1 N//=self.smallest_prime_factor[N] else: for p in self.primes: while N%p==0: N//=p factors[p]+=1 if N<p*p: if N!=1: factors[N]+=1 break if N<=len(self.smallest_prime_factor)-1: while N!=1: factors[self.smallest_prime_factor[N]]+=1 N//=self.smallest_prime_factor[N] break else: if N!=1: factors[N]+=1 return factors def Divisors(self,N): assert N>0 divisors=[1] for p,e in self.Factorize(N).items(): pow_p=[1] for _ in range(e): pow_p.append(pow_p[-1]*p) divisors=[i*j for i in divisors for j in pow_p] return divisors def Is_Prime(self,N): return N==self.smallest_prime_factor[N] def Totient(self,N): for p in self.Factorize(N).keys(): N*=p-1 N//=p return N def Mebius(self,N): fact=self.Factorize(N) for e in fact.values(): if e>=2: return 0 else: if len(fact)%2==0: return 1 else: return -1 N=int(input()) P=Prime(3*N) primes=[p for p in P.primes if p<=N] cnt=defaultdict(int) le=len(primes) ans=0 i=len(P.primes)-1 for b in range(le-1,-1,-1): for a in range(b-1,-1,-1): ans+=cnt[primes[a]+primes[b]] while i and P.primes[i-1]-primes[b]>1: i-=1 for j in range(i,len(P.primes)): p=P.primes[j] if p-primes[b]>=2*primes[b]: break if (p-primes[b])%2 and not P.Is_Prime(p-primes[b]-2): continue cnt[p-primes[b]]+=1 print(ans)