A trigonometry function
Practice
2.6 (17 votes)
Basic math
C++
Math
Problem
17% Success 1340 Attempts 50 Points 0.5s Time Limit 256MB Memory 1024 KB Max Code
You are given a function \(f(n) = 2 \times 7^{n/2} \times \cos(n\theta) + n \times 4^n\), where \(\theta = \tan^{-1}{\frac{\sqrt3}{2}}\).
You are also given two integers \(p\) and \(q\). Your task is to find the value of \(\sum _\limits{n=p}^{n=q}f(n)\) (modulo \(10^9+21\)).
Input format
- The first line consists of an integer \(T\) denoting the number of test cases.
- Each of the next \(T\) lines consists of two space-separated integers \(p\) and \(q\).
Output format
Print \(T\) lines each containing a single integer corresponding to the required value \(\sum _\limits{n=p}^{n=q}f(n)\). Print the answer modulo \(10^9+21\).
Constraints
\(1\le T \le 10^2\)
\(0\le p \le q \le 10^{18}\)
Sample Input
1 0 1
Sample Output
10
Explanation
\(f(0)=2\)
\(f(1)=8\)
\(S=f(0)+f(1)=10\)
Code Editor
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Submissions
Please login to view your submissions
Similar Problems
Points:50
2 votes
Tags:
C++Basic MathMathamaticsMath
Points:50
16 votes
Tags:
MathematicsMedium-HardMathematicsMathamatics
Points:50
24 votes
Tags:
Math BasicAlgorithmsBasic MathMath
Editorial
Login to unlock the editorial
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor