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
2012-10-12 04:57:50 RAJDEEP GUPTA
@Tjandra: Thanks. So, the logic is correct. But then I don't know where I'm failing.

@loser: Can you please give a test case where my code fails?

EDIT: Ok, now it's AC. Thanks. :)

Last edit: 2012-06-29 05:48:04
2012-10-12 04:57:50 (Tjandra Satria Gunawan)(曾毅昆)
@RAJDEEP GUPTA: Yes it's correct...
2012-10-12 04:57:50 RAJDEEP GUPTA
I'm getting 7071292 for 10^11. Is it correct? I'm getting WA.
2012-10-12 04:57:50 Aradhya
@Himanshu:: I agree with you :) but then i have to move this one to tutorial :) so no gain at all for users :)
2012-10-12 04:57:50 Himanshu Srivastava
if you have to change the limits...you could add a harder version this is not fair....but well now the problem is pretty good :)
2012-10-12 04:57:50 Aradhya
@tjandra ,,, congo!! and nice solution :)
2012-10-12 04:57:50 (Tjandra Satria Gunawan)(曾毅昆)
hmm... I solved 3 sequence problems in a day.... ~_~

@loser: Thanks, nice problem ;)

Last edit: 2012-06-28 17:12:25
2012-10-12 04:57:50 Mukesh Tiwari
thnx 15972125841321
my soln at the top \m/
...heheh LOL kar dia Problem Setter ne.. :P

Last edit: 2012-06-28 20:13:45
2012-10-12 04:57:50 Mukesh Tiwari
my op fails at higher inputs :(
2012-10-12 04:57:50 Mukesh Tiwari
@ 15972125841321
give me some tough test cases
plese
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.