結果
問題 |
No.502 階乗を計算するだけ
|
ユーザー |
|
提出日時 | 2017-04-16 19:23:44 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 641 bytes |
コンパイル時間 | 4,262 ms |
コンパイル使用メモリ | 103,296 KB |
実行使用メモリ | 23,168 KB |
最終ジャッジ日時 | 2024-07-19 04:04:54 |
合計ジャッジ時間 | 4,381 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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.
ソースコード
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; class Program { static long LPow (long x, long n) { if (n == 0) return 1; return x * LPow(x, n - 1); } static void Main(string[] args) { long n = Int64.Parse( Console.ReadLine() ); long aa = LPow(10, 18); long ans = 1; long r1, r2, n2; long m = LPow(10, 9) + 7; Math.DivRem(n, m, out n2); for (int i = 1; i < n2 + 1; i++) { Math.DivRem(ans, m, out r1); Math.DivRem(i, m, out r2); ans = r1 * r2; } long result; Math.DivRem(ans, m, out result); Console.WriteLine(result); } }