結果
| 問題 | No.500 階乗電卓 |
| コンテスト | |
| ユーザー |
akitsu818
|
| 提出日時 | 2017-04-30 23:16:56 |
| 言語 | Java (openjdk 23) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 556 bytes |
| 記録 | |
| コンパイル時間 | 2,993 ms |
| コンパイル使用メモリ | 74,468 KB |
| 実行使用メモリ | 832,116 KB |
| 最終ジャッジ日時 | 2024-09-14 00:03:16 |
| 合計ジャッジ時間 | 6,665 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 3 |
| other | MLE * 1 -- * 19 |
ソースコード
import java.util.Scanner;
public class Main {
public static void main(String args[]){
Scanner cin = new Scanner(System.in);
long N = cin.nextLong();
cin.close();
long tmp = 0L;
int sub=0;
tmp = func(N);
if(N>=16&&tmp<(long)Math.pow(10, 11)){
sub = 12-String.valueOf(tmp).length();
for(int i =0;i<sub;i++){
System.out.print("0");
}
}
System.out.println(tmp);
}
static long func(long n){
if(n==0L){
return 1;
}else{
if(func(n-1)==0L){
return 0L;
}
return (n*func(n-1))%(long)Math.pow(10, 12);
}
}
}
akitsu818