ARD1 - The Easiest Sequence Of the World!!

 

I just found the easiest and funny sequence ever !
Your task is simple. Just write a program to find the Nth term of this sequence!!
The sequence is as follows::
3, 8, 12, 17, 22, 28, 35....

 

I just found the easiest and funny sequence ever !

Your task is simple. Just write a program to find the Nth term of this sequence!!

The sequence is as follows::

3, 8, 12, 17, 22, 28, 35....

 

 

Input

 

First line contains t = number of test cases

and then next t lines follow n. 

1<=n<=10^11

Note-- Value of n is modified to encourage better solutions!

Output

 

Just the output the nth term modulo 123456789

 

Example

Input:
3
1
2
3

Output:
3
8
12

Added by:Aradhya
Date:2012-06-28
Time limit:0.100s
Source limit:10000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:ASM32-GCC MAWK BC C-CLANG C NCSHARP CSHARP C++ 4.3.2 CPP CPP14 CPP14-CLANG C99 COBOL COFFEE D-CLANG D-DMD DART ELIXIR FANTOM FORTH GOSU GRV JS-MONKEY JULIA KTLN NIM NODEJS OBJC OBJC-CLANG OCT PICO PROLOG PYPY PYPY3 PY_NBC R RACKET RUST CHICKEN SQLITE SWIFT UNLAMBDA VB.NET
Resource:Own Problem

hide comments
2022-04-17 13:09:55
what is the formula guys ? :))
2018-03-20 04:22:18
hello
2015-09-30 08:49:37
Time limit is exceeding....what should i do
2014-01-17 04:40:21 leafmoon
I found the logic, but how should I calculate such a large number...

[edit] OK I got it. Now my task is calculate *that* in O(logn).
[edit2] Accepted. ^^

Last edit: 2014-01-17 19:32:50
2013-03-19 06:50:40 Ouditchya Sinha
@Tjandra, I guess you are right, after predicting the sequence it's no different than other exponentiation problems... :)
2013-03-18 04:17:04 Ouditchya Sinha
This question deserves to be in classical section... Why moved to riddle? I lost around 0.5 points. :(
Ans(Tjandra): Because this problem doesn't have clear task/what to do, It's like "guessing" game.. Those problem called "riddle".. Don't sad, I lost points too.. I hope someday "riddle" problem has own scoring formula..

Last edit: 2013-03-18 08:00:19
2013-03-17 23:03:52 Francky
Moved to "riddle".
2013-03-15 23:03:40 DivineAtheist
huh...cant think of the world's most difficult sequence...if this is the easy one...:P
2013-02-23 02:27:58 Ouditchya Sinha
Awesome problem, AC in 1st attempt :) ... @Tjandra Thank you for the tip...
2013-02-17 11:54:09 chicku
@Tjandra i invite u for a coding challenge man . just tell me the place nd time
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.