結果
| 問題 | No.500 階乗電卓 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-07-28 15:17:09 |
| 言語 | C# (.NET 10.0.201) |
| 結果 |
AC
|
| 実行時間 | 64 ms / 2,000 ms |
| コード長 | 786 bytes |
| 記録 | |
| コンパイル時間 | 6,454 ms |
| コンパイル使用メモリ | 173,836 KB |
| 実行使用メモリ | 194,316 KB |
| 最終ジャッジ日時 | 2026-04-22 03:30:24 |
| 合計ジャッジ時間 | 8,939 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge3_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (83 ミリ秒)。 main -> /home/judge/data/code/bin/Release/net10.0/main.dll main -> /home/judge/data/code/bin/Release/net10.0/publish/
ソースコード
using System;
using System.Collections.Generic;
using System.Linq;
namespace yukicoder
{
public class Program
{
public static void Main()
{
var n = long.Parse(Console.ReadLine());
if (n < 60)
{
Console.WriteLine(factorial(n));
}
else
{
Console.WriteLine("000000000000");
}
}
static string factorial(long a)
{
long f = 1;
var b = (long)Math.Pow(10, 12);
var c = true;
while (a > 0)
{
f *= a;
if (f > b)
{
f %= b;
c = false;
}
a--;
}
if (c)
{
return f.ToString();
}
else
{
return f.ToString("000000000000");
}
}
}
}