結果
| 問題 | No.3388 Sum of Function |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-11-28 21:24:13 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 40 ms / 2,000 ms |
| コード長 | 451 bytes |
| コンパイル時間 | 170 ms |
| コンパイル使用メモリ | 82,084 KB |
| 実行使用メモリ | 53,764 KB |
| 最終ジャッジ日時 | 2025-11-28 21:24:16 |
| 合計ジャッジ時間 | 2,364 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
ソースコード
import math
def eratosthenes(n):
sieve=[True]*(n+1)
for i in range(int(math.sqrt(n))+1):
if i<2:
sieve[i]=False
elif sieve[i]:
for j in range(2,n//i+1):
sieve[i*j]=False
return sieve
A,B=map(int,input().split())
sieve=eratosthenes(B)
primes=[]
for i in range(A,B+1):
if sieve[i]:primes.append(i)
def f(x):
return x**3-x**2+x+1
ans=0
for p in primes:
ans+=f(p)
print(ans)