Find Nth Term
All submissions for this problem are available.
Find the nth term of a series for which if it is given that if n is less than 2 then the nth term is 1 and if n is greater than or equals to 2 and less than 4 nth term is 2 else nth term will be equal to the difference of (n+2)th term and (n-2)th term.
tn = t(n+2) - t(n-2) Where n ≥ 4
The answer could be very large, so compute it modulo with 109 + 7
- The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows.
- The first and only line of each test case contains a single integer N
- For each test case, output a single line containing the nth term of the series with modulo 109 + 7
- 1 ≤ T ≤ 105
- 1 ≤ N ≤ 105
Input: 2 2 5 Output: 2 3
Example case 1.for n=2 , t2 = 2
|Tags||dynamic-programming, easy, ince2019, prajapat786, prajapat786|
|Time Limit:||0.5 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, SQL, kotlin, PERL6, TEXT, SCM chicken, PYP3, CLOJ, R, COB, FS|
Fetching successful submissions