Submit  All submissions  Best solutions  Back to list 
PASCAL_T  Pascal’s triangle 
Wersja polska  English version 
For given integer n, your task will be to print nth line of Pascal's triangle.
1  0th line
1 1  1st line
1 2 1  2nd line
1 3 3 1  3rd line
1 4 6 4 1  4th line
...
Input
The first line of the standard input contains one integer t (t<101) which is the number of test cases.
In each of the next t lines there is one integer n (0<=n<101).
Output
For each n, print nth line of Pascal's triangle.
Example
Input:
2
7
0
Output:
1 7 21 35 35 21 7 1
1
Added by:  Piotr Ką kol 
Date:  20091222 
Time limit:  6s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: SCM qobi 
Resource:  Pascal's triangle 
hide comments


20131207 21:05:46 Piotr KÄ…kol
By using dc. 

20131207 15:26:08 Linghui Liu
@piotr, can you give a hint to get around awk big problem? With 253338471349988640(about 2^58)*5 awk gives wrong answer. 

20131122 15:10:19 Linghui Liu
Just curious about the awk AC. How can awk avoid the big problem? 

20130426 21:50:34 Piotr KÄ…kol
@jayavasanth  For n=45 you print negative numbers. 

20121122 13:15:30 jayavasanth
i m getting answer correct answer for all inputs... but it says wrong output :( idk why 

20100427 16:00:25 Piotr KÄ…kol
No problem. I'm glad that I helped You at least in that way. ;) 

20100427 06:54:29 Zoltán Zámbori
Thank You! Now i see that bigrat gives "wrong answare" too. Sorry for wasting Your time. 

20100426 14:21:42 Piotr KÄ…kol
If You want to check Your answers here is output for 100th line of Pascal's triangle. 

20100425 16:17:19 Zoltán Zámbori
I use bigrat in the code. Bigint give "wrong result". At home it needs 32 sec to print n=100. (I don't know the result is correct or not.) Last edit: 20100425 16:35:24 

20100425 15:12:33 Piotr KÄ…kol
So I increased time limit to 20sec and it's still not enought for Your TLE submitions. As for big numbers in Perl it's yet bigint which satisfy task conditions. There are also very few tests so it shouldn't be a problem with even strict time limit. 