結果

問題 No.502 階乗を計算するだけ
ユーザー masakt
提出日時 2017-04-08 00:09:20
言語 C#(csc)
(csc 3.9.0)
結果
TLE  
実行時間 -
コード長 501 bytes
コンパイル時間 995 ms
コンパイル使用メモリ 108,896 KB
実行使用メモリ 32,732 KB
最終ジャッジ日時 2024-07-16 03:29:47
合計ジャッジ時間 5,161 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 32 TLE * 1 -- * 19
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections.Generic;

class P
{
    static void Main(string[] _)
    {
        UInt64 n = UInt64.Parse(Console.ReadLine());
        UInt64 r = 1;
        for (UInt64 i = n % 1000000007; i >= 1; i--)
        {
            if (i == 0)
            {
                r = 0;
                break;
            }
            r = r * i;
            if (1000000007 <= r)
            {
                r = r % 1000000007;
            }
        }
        Console.WriteLine(r);
    }
}
0