All Tracks Problem

Pradyumn And Pseudo Random Numbers
Tag(s):

Easy, Implementation

Problem
Editorial
Analytics

Pradyumn recently studied a new topic called Random Numbers and Pseudo Random Numbers. He came across a fact that all the programming languages never creates perfectly random numbers. They follow a certain logic to create random numbers. That's why numbers generated are called Pseudo Random Numbers. Now, Pradyumn thought to make Pseudo Random Numbers himself. He created a following function

generateRandomNumbers(size) {
    range = 1000000007
    multiplierOne = 2017
    multiplierSecond = 2027
    lastNumber = 0
    secondLastNumber = 1
    maxNumberGeneratedTillNow = 0
    list[size] // list of generated numbers
    for(I = 1;I <= size; ++I) {
        newNumber = (lastNumber * multiplierOne + secondLastNumber * multiplierSecond + maxNumberGeneratedTillNow) % range + 1
        secondLastNumber = lastNumber
        lastNumber = newNumber 
        list.ADD(newNumber)
    }
return list
Pradyumn asked Anmol to test his logic. Anmol thought to check certain numbers that can be created by this number or not. Pradyumn is tired after creating the logic. Pradyumn needs your help to answer Anmol Queries.

INPUT CONSTRAINTS
\(1 \le size \le 10^6\)
\(1 \le q \le 10^5\)
\(1 \le q_i \le 1000000007\)

INPUT FORMAT
Two space separated integers size and Q , where size denotes the size of randomly generated numbers and Q denotes number of queries.
Q number of lines describing the query value on each line given by Anmol.

OUTPUT FORMAT
If number can be created from given values and function, output "YES" else "NO" without quotes

SAMPLE INPUT
1 2
2028
2018
SAMPLE OUTPUT
YES
NO
Explanation

On generating random numbers according to above function(do it yourself). One number will be created which is 2028. As the Anmol asked for 2028. Answer will be "YES". And answer for 2018 will be "NO".

Time Limit: 1,0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB
Marking Scheme: Marks are awarded when all the testcases pass.
Allowed Languages: Bash, C, C++, C++14, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, JavaScript(Rhino), JavaScript(Node.js), Julia, Kotlin, Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala, Swift, Swift-4.1, TypeScript, Visual Basic

CODE EDITOR

Initializing Code Editor...
Your Rating:

Contributor

This Problem was Asked in

The LNM Institute of Information Technology

Challenge Name

LNMIIT Algorithms Cup - June 2017

OTHER PROBLEMS OF THIS CHALLENGE
Уведомления
View All Notifications

?