PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#SP0000057. Tổng có trọng số trên đoạn nguyên tố (Weighted Sum of Primes in an Interval)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Tổng có trọng số trên đoạn nguyên tố (Weighted Sum of Primes in an Interval)
Weighted Sum of Primes in an Interval
Source: LQDOJ
Version: Phuoc Hung OJ Extended
Problem Statement
Given positive integers , list all primes in the inclusive range in increasing order . The first prime has weight , the second weight , and prime has weight . Compute modulo . If the interval contains no primes, the sum is .
Input
One line contains two positive integers and .
Output
Print one integer in : the weighted sum reduced modulo .
Subtasks
- Subtask 1 (20 points): .
- Subtask 2 (20 points): .
- Subtask 3 (60 points): .
Examples
Input
3 7
Output
34
Explanation
The primes in are . Their weights are , so the terms are , , and . The sum is less than ; print 34.