Three is CrowdProblem code: CROWD |
All submissions for this problem are available.
Two's company, three's a crowd!
It's been one year since Chef met his brother. Last year, his younger brother came to visit him during this time of the year. This year, the Chef is planning to go visit his brother. Chef's brother has planned to throw a "Welcome Party" for him. He wants to invite people from his neighbourhood (i.e. from the street where he lives). There are N houses on the street in a single line (not considering the brother's house). He wants the party to be fun and he will not like to invite people who might spoil the mood of the party. If people are invited from three consecutive houses on the street, they might create trouble. As they say, three's a crowd! He doesn't want to ruin the Chef's Welcome Party and so he will not want to send invites to any three consecutive houses. He wants you to tell him how many ways are there for him to go wrong. Note that he can play safe by not inviting anyone to avoid a crowd.
Input:
First line of the input contains a single integer T, the number of test cases.
Each test case contains a line containing a single integer N described above.
Output:
For each test case output a single integer denoting the number of ways the brother can go wrong with planning the party.
The answer can get quite large. So output the total number of ways modulo 109+7.
Constraints:
1<=T<=10000 1<=N<=1015
Example:
Input:2 3 4Output:
1 3Explanation: Case 1: The only way he can go wrong is by inviting all the houses.
Case 2: First way of getting wrong is by inviting houses (1,2,3). Second way to get wrong is by inviting houses (2,3,4). Third way of going wrong is by inviting all 4 houses i.e. (1,2,3,4).
| Author: | vamsi_kavala |
| Tester: | laycurse |
| Editorial | http://discuss.codechef.com/problems/CROWD |
| Date Added: | 5-08-2012 |
| Time Limit: | 5 sec |
| Source Limit: | 50000 Bytes |
| Languages: | ADA, ASM, BASH, BF, C, C99 strict, CAML, CLOJ, CLPS, CPP 4.0.0-8, CPP 4.3.2, CS2, D, ERL, FORT, FS, GO, HASK, ICK, ICON, JAR, JAVA, JS, LISP clisp, LISP sbcl, LUA, NEM, NICE, NODEJS, PAS fpc, PAS gpc, PERL, PERL6, PHP, PIKE, PRLG, PYTH, PYTH 3.1.2, RUBY, SCALA, SCM guile, SCM qobi, ST, TCL, TEXT, WSPC |
Comments
SUCCESSFUL SUBMISSIONS
Fetching successful submissions


Excuse me ? 1.
Every question in every
@admin for N=5 {1 2 3 4 5}
IMP : Is the time limit not
Contestants are requested NOT
can any1 tell me Y it is
don't use modulus operator
my approch is corrent...
Does first test is equal to
nice ques.....
is {1,2,3,5 } a valid
mod is giving some
@mido_mavrick: time limit
@ kp25, I think {1,2,3,5 } is
@deinier, still getting wrong
Is the order important? say
plz give correct ans for any
The best way to verify your
my code is running on my
even my soln is timing out. I
Is there any problem with the
@radhika123, rixdi, sidd081:
Can someone give me a
Nevermind, I've come up with
@all Can anyone tell if
@karuma 12345 is same as
@amannith Yes, I realized it
@admin: we are not able to
I am getting runtime error
i am getting a wrong answer.
@admin A problem is also seen
@kuruma I respectfully
I am getting runtime error
@dmdmroy7 read carefully: "
y runtime error while using
It is correct yes!!
@kuruma does { 1 2 3 4 } and
@kuruma: You're constantly
PLEASE DO NOT DISCUSS TEST
wa wa wa
@all who got accepted: "Note
6 tyms submit..! wa :( @least
@kp25 I believe mod is always
wow finally ac after so many
TLE.. TLE... TLE... infinite
@admin... hey I got my code
If a code is judged and ends
@admin I had run my code for
@admin is there a problem
@ admin : same problem. Is
finally accepted aftr 15
seems like has solution has
@admin i am also getting
Guys it seems like there was
does this type of question is
@admin please do provide
@admin: 5 sec is for 1 test
@admin: i also checked for
same old school question with
ridder, this is an old school
It seems to be that my
sometimes Modulo hurts really
I doff my hats for those who
can anyone please provide a
please provide test cases
finally accepted.... high
TLE at least this time 'not