結果

問題 No.500 階乗電卓
ユーザー mori_chibimori_chibi
提出日時 2017-08-18 16:39:04
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 54 ms / 2,000 ms
コード長 816 bytes
コンパイル時間 2,016 ms
コンパイル使用メモリ 104,648 KB
実行使用メモリ 23,212 KB
最終ジャッジ日時 2023-09-07 08:43:40
合計ジャッジ時間 4,006 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
19,152 KB
testcase_01 AC 53 ms
23,068 KB
testcase_02 AC 52 ms
23,060 KB
testcase_03 AC 54 ms
23,056 KB
testcase_04 AC 53 ms
23,108 KB
testcase_05 AC 50 ms
21,096 KB
testcase_06 AC 50 ms
21,104 KB
testcase_07 AC 49 ms
21,016 KB
testcase_08 AC 49 ms
23,028 KB
testcase_09 AC 50 ms
23,160 KB
testcase_10 AC 51 ms
20,984 KB
testcase_11 AC 49 ms
20,944 KB
testcase_12 AC 52 ms
21,100 KB
testcase_13 AC 54 ms
20,992 KB
testcase_14 AC 51 ms
21,100 KB
testcase_15 AC 49 ms
21,104 KB
testcase_16 AC 51 ms
23,040 KB
testcase_17 AC 51 ms
23,096 KB
testcase_18 AC 52 ms
22,988 KB
testcase_19 AC 50 ms
20,944 KB
testcase_20 AC 53 ms
20,972 KB
testcase_21 AC 52 ms
21,176 KB
testcase_22 AC 51 ms
23,212 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;

namespace FactCalc
{
    class Program
    {
        static void Main(string[] args)
        {
            const long c = 1000000000000;
            long n = long.Parse(Console.ReadLine());
            bool f = false;
            if (n < 50)
            {
                for (long i = n - 1; i > 1; i--)
                {
                    if (f || n * i / c >= 1)
                    {
                        f = true;
                    }
                    n = (n * i) % c;
                }
            }
            else
            {
                n = 0;
                f = true;
            }
            string s = n.ToString("#");
            if (f)
            {
                s = s.PadLeft(12).Replace(" ", "0");
            }
            Console.WriteLine(s);
        }
    }
}
0