ARD1 - The Easiest Sequence Of the World!!

no tags 

 

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

hide comments
RAJDEEP GUPTA: 2012-10-12 04:57:50

@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
(Tjandra Satria Gunawan)(曾毅昆): 2012-10-12 04:57:50

@RAJDEEP GUPTA: Yes it's correct...

RAJDEEP GUPTA: 2012-10-12 04:57:50

I'm getting 7071292 for 10^11. Is it correct? I'm getting WA.

Aradhya: 2012-10-12 04:57:50

@Himanshu:: I agree with you :) but then i have to move this one to tutorial :) so no gain at all for users :)

Himanshu Srivastava: 2012-10-12 04:57:50

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 :)

Aradhya: 2012-10-12 04:57:50

@tjandra ,,, congo!! and nice solution :)

(Tjandra Satria Gunawan)(曾毅昆): 2012-10-12 04:57:50

hmm... I solved 3 sequence problems in a day.... ~_~

@loser: Thanks, nice problem ;)

Last edit: 2012-06-28 17:12:25
Mukesh Tiwari: 2012-10-12 04:57:50

thnx 15972125841321
my soln at the top \m/
...heheh LOL kar dia Problem Setter ne.. :P

Last edit: 2012-06-28 20:13:45
Mukesh Tiwari: 2012-10-12 04:57:50

my op fails at higher inputs :(

Mukesh Tiwari: 2012-10-12 04:57:50

@ 15972125841321
give me some tough test cases
plese


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