Sequences
Practice
4.2 (17 votes)
Easy
Basic math
Mathematics
Mathematics
Problem
92% Success 6476 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code

You are given a function that is similar to the Fibonacci series.

The function \(f\) is represented as follows: 

\(f(1)=a,f(2)=b,f(i)=f(i-1)+f(i-2)\) for integer \(i\geq 3\)

You do not know the numbers that are available in the sequence. You are also given \(q\) queries. Each query contains a number \(x\). Your task is to determine whether a positive \(i^{th}\) integer satisfies \(f(i)=x\).

Input format

  • First line: Two integers \(a,\ b\) (\(0\leq a,b\leq 10^{18}\))
  • Second line: An integer \(q\) (\(0\leq q\leq 10^6\))
  • Each of the \(q\) lines: An integer \(x_i\) (\(0\leq x_i\leq 10^{18}\))

Output format

Print the answer for each of the \(q\) queries in a new line. Therefore, the output must contain q lines. Print \(YES\) if there is an integer that satisfies the condition. Otherwise, print \(NO\).

 

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

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
7 votes
Tags:
MathNumber theoryBasic MathAlgorithms
Points:20
24 votes
Tags:
Ad-HocBasic ProgrammingEasyMathematicsOpenApprovedMathamatics
Points:20
Tags:
Easy