No.3388 Sum of Function
タグ : / 解いたユーザー数 116
作問者 :
yt142857
Germanium32
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
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。