荔园在线

荔园之美,在春之萌芽,在夏之绽放,在秋之收获,在冬之沉淀

[回到开始] [上一篇][下一篇]


发信人: kaman (天外飞仙), 信区: ACMICPC
标  题: 小题一道
发信站: 荔园晨风BBS站 (Fri Sep  3 10:15:33 2004), 站内信件

看谁做得快而已……



                          Factorials

The factorial of an integer N, written N!, is the product of all the in
tegers from 1 through N inclusive. The factorial quickly becomes very la
rge: 13! is too large to store in a 32-bit integer on most computers, an
d 70! is too large for most floating-point variables. Your task is to fi
nd the rightmost non-zero digit of n!. For example, 5! = 1 * 2 * 3 * 4 *
 5 = 120, so the rightmost non-zero digit of 5! is 2. Likewise, 7! = 1 *
 2 * 3 * 4 * 5 * 6 * 7 = 5040, so the rightmost non-zero digit of 7! is
4.
PROGRAM NAME: fact4
INPUT FORMAT
A single positive integer N no larger than 4,220.
SAMPLE INPUT (file fact4.in)

7

OUTPUT FORMAT
A single line containing but a single digit: the right most non-zero di
git of N! .
SAMPLE OUTPUT (file fact4.out)

4


 --
       灬 灬 灬灬 灬灬  灬 灬 ════════════════════╗╮
   ╭╯  灬 灬▂╱   _灬灬ジ  ヾ                                   灬╰╗
   ║ 灬◢◢ "▔ 灬╱          灵台无计逃神矢  风雨如磐暗故园  ▁  灬|"|║
   ║     ◤,  |,╱_ ◣◣      寄意寒星荃不察  我以我血荐轩辕▕心▏  ◣|║
   ║     _,|\▄/ \▌◥                                        ▔ヾ◥◥|║
   ╚═ "\▌| ▔ | | /" ════════════════════════╯

※ 来源:·荔园晨风BBS站 bbs.szu.edu.cn·[FROM: 192.168.111.200]


[回到开始] [上一篇][下一篇]

荔园在线首页 友情链接:深圳大学 深大招生 荔园晨风BBS S-Term软件 网络书店