Submit | All submissions | Best solutions | Back to list |
FACT_FUN - H Function |
Wersja polska | English version |
H(x) equals to sum of all digits of x. Moreover, if H(x)>9 then H(x)=H(H(x)).
Input
The first line of the standard input contains one integer t (t<100001) - the number of test cases.
In each of the next t lines there is one number x (x<106).
Output
For each test You have to print H(x!).
Example
Input: 2
1
5
Output: 1
3
Added by: | Piotr Kąkol |
Date: | 2011-09-11 |
Time limit: | 5s-10s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: SCM qobi |
Resource: | Copy of HFUN with bigger time limit and all available languages |
hide comments
|
|||||
2013-09-12 19:36:13 Piotr KÄ…kol
Mitch, you've created a monster! :D |
|||||
2013-09-12 18:28:59 Jander
I'm rather starting to like sed :-) |
|||||
2011-09-12 22:25:36 Hallvard Norheim Bø
@HWK: Let us see if you can match this Python! |
|||||
2011-09-12 10:32:30 HWK
@hallvabo: Seems there's much work for you. ;-) |
|||||
2011-09-11 21:20:19 Hallvard Norheim Bø
@Piotr: Thanks! :) |
|||||
2011-09-11 21:15:27 Piotr KÄ…kol
@hallvabo - You're right. I just copied the restrictions from HFUN. Changed and rejudged. :-) And here's Your promised 50-char code. :-) |
|||||
2011-09-11 20:39:02 Hallvard Norheim Bø
@Piotr: It's submission #5642993. Doesn't work for such a huge number of testcases. What's the point of having a 100000 of them anyway? A hundred or a thousand would've been plenty enough ;) |
|||||
2011-09-11 20:25:02 Piotr KÄ…kol
@hallvabo - Weren't You talking about 50-char solution for that task? |