|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
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).
For each n, print nth line of Pascal's triangle.
1 7 21 35 35 21 7 1
|Added by:||Piotr Kąkol|
|Cluster:||Cube (Intel G860)|
|Languages:||All except: SCM qobi|
2013-12-07 21:05:46 Piotr KÄ…kol
By using dc.
2013-12-07 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.
2013-11-22 15:10:19 Linghui Liu
Just curious about the awk AC. How can awk avoid the big problem?
2013-04-26 21:50:34 Piotr KÄ…kol
@jayavasanth - For n=45 you print negative numbers.
2012-11-22 13:15:30 jayavasanth
i m getting answer correct answer for all inputs... but it says wrong output :(
2010-04-27 16:00:25 Piotr KÄ…kol
No problem. I'm glad that I helped You at least in that way. ;-)
2010-04-27 06:54:29 Zoltán Zámbori
Thank You! Now i see that bigrat gives "wrong answare" too. Sorry for wasting Your time.
2010-04-26 14:21:42 Piotr KÄ…kol
If You want to check Your answers here is output for 100th line of Pascal's triangle.
2010-04-25 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: 2010-04-25 16:35:24
2010-04-25 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.