2012/03/01

[zerojudge] d114 好累的小玫

題目:https://zerojudge.tw/ShowProblem?problemid=d114
說明:Java 跟 Python 好棒,硬算也是 OK。

Java 版
import java.math.BigInteger;

public class D114 {

    static BigInteger level(int n){
        BigInteger ans = new BigInteger("1");
        for(int i = 1; i <= n; i++)
            ans = ans.multiply(new BigInteger(i+""));
        return ans;
    }

    public static void main(String[] args) {
        BigInteger ans = new BigInteger("1");
        for(int a = 1; a <= 100; a++){
            BigInteger e = level(a);
            ans = ans.multiply(e);
        }
        char [] chars = ans.toString().toCharArray();
        for (char c : chars)
            System.out.println(c);
    }
}
Python 版 (2022.07)
def level(n):
    ans = 1
    for i in range(1, n + 1):
        ans *= i
    return ans


s = 1
for a in range(1, 101):
    s *= level(a)
for c in list(str(s)):
    print(c)

沒有留言:

張貼留言