問題一覧 > 通常問題

No.3388 Sum of Function

レベル : / AI推定難易度 : 130 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 116
作問者 : yu23578 / テスター : GaLLium yt142857 aa36 Germanium32
お気に入りにしたユーザー ProblemId : 12777 / 自分の提出
問題文最終更新日: 2025-11-28 15:05:55
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 490 (順位表) の他の問題:

Problem Statement

Define $f(x) = x^3-x^2+x^1+1$. Find the sum of $f(x)$ over all primes between $A$ and $B$, inclusive.

What is a prime? A prime is a positive integer other than $1$ that has no positive divisors other than $1$ and itself.

Constraints

  • $1 \le A \le B \le 100$
  • All inputs are integers.

Input

$A\ B$

Output

Output the sum of $f(x)$ over all primes between $A$ and $B$, inclusive.
Print a newline at the end.

Sample

Sample 1
Input
2 8
Output
437

There are $4$ primes between $2$ and $8$, inclusive: $2,3,5,7$, and
$f(2) = 2^3-2^2+2^1+1 = 7$
$f(3) = 3^3-3^2+3^1+1 = 22$
$f(5) = 5^3-5^2+5^1+1 = 106$
$f(7) = 7^3-7^2+7^1+1 = 302$

Therefore, output $f(2)+f(3)+f(5)+f(7) = 437$.

Sample 2
Input
8 10
Output
0

There are no primes between $8$ and $10$, inclusive, so the answer is $0$.

Sample 3
Input
29 29
Output
23578

I just wanted to do this. The site I used as a reference

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。