結果

問題 No.500 階乗電卓
ユーザー fjafjafjafjafjafja
提出日時 2017-08-23 01:40:57
言語 Java21
(openjdk 21)
結果
AC  
実行時間 128 ms / 2,000 ms
コード長 544 bytes
コンパイル時間 3,712 ms
コンパイル使用メモリ 73,552 KB
実行使用メモリ 56,348 KB
最終ジャッジ日時 2023-09-07 08:43:52
合計ジャッジ時間 7,687 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
55,760 KB
testcase_01 AC 125 ms
55,968 KB
testcase_02 AC 123 ms
55,824 KB
testcase_03 AC 124 ms
55,864 KB
testcase_04 AC 123 ms
55,864 KB
testcase_05 AC 127 ms
55,636 KB
testcase_06 AC 124 ms
55,692 KB
testcase_07 AC 124 ms
55,700 KB
testcase_08 AC 124 ms
56,132 KB
testcase_09 AC 123 ms
56,040 KB
testcase_10 AC 126 ms
56,348 KB
testcase_11 AC 123 ms
56,076 KB
testcase_12 AC 123 ms
56,008 KB
testcase_13 AC 126 ms
55,604 KB
testcase_14 AC 128 ms
55,704 KB
testcase_15 AC 123 ms
56,000 KB
testcase_16 AC 124 ms
56,012 KB
testcase_17 AC 123 ms
55,804 KB
testcase_18 AC 125 ms
55,664 KB
testcase_19 AC 122 ms
55,864 KB
testcase_20 AC 125 ms
55,892 KB
testcase_21 AC 124 ms
55,368 KB
testcase_22 AC 125 ms
55,888 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class N500
{
	public static void main(String[] args)
	{
		Scanner sc=new Scanner(System.in);
		long N=sc.nextLong();
		long ans =1;
		String sans="";
		if(N<50)
		{
		for(int i=2;i<=N;i++)
		{
			ans*=i;
			ans%=(long)Math.pow(10, 12);

		}
		sans=String.valueOf(ans);
		if(N>14)
			{
				if(sans.length()<12)
				{
					int b=12-sans.length();
					for(int i=0;i<b;i++)
					{
						sans="0"+sans;
					}
				}
			}
		else
			{

			}
		}
		else
		{
			sans="000000000000";
		}
		System.out.println(sans);
	}
}
0