結果

問題 No.502 階乗を計算するだけ
ユーザー fal_rndfal_rnd
提出日時 2017-04-07 23:09:12
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 587 bytes
コンパイル時間 4,457 ms
コンパイル使用メモリ 71,092 KB
実行使用メモリ 56,396 KB
最終ジャッジ日時 2023-09-23 02:36:08
合計ジャッジ時間 9,897 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
55,564 KB
testcase_01 AC 128 ms
55,700 KB
testcase_02 AC 129 ms
55,600 KB
testcase_03 AC 126 ms
55,944 KB
testcase_04 AC 126 ms
55,760 KB
testcase_05 AC 125 ms
55,768 KB
testcase_06 AC 125 ms
55,780 KB
testcase_07 AC 126 ms
55,704 KB
testcase_08 AC 125 ms
55,712 KB
testcase_09 AC 128 ms
55,492 KB
testcase_10 AC 124 ms
55,704 KB
testcase_11 AC 124 ms
55,716 KB
testcase_12 AC 125 ms
56,032 KB
testcase_13 AC 126 ms
55,896 KB
testcase_14 AC 127 ms
55,700 KB
testcase_15 AC 126 ms
55,916 KB
testcase_16 AC 126 ms
55,608 KB
testcase_17 AC 127 ms
55,388 KB
testcase_18 AC 128 ms
55,552 KB
testcase_19 AC 129 ms
55,560 KB
testcase_20 AC 125 ms
55,652 KB
testcase_21 AC 125 ms
53,728 KB
testcase_22 AC 136 ms
55,572 KB
testcase_23 AC 130 ms
55,412 KB
testcase_24 AC 133 ms
56,396 KB
testcase_25 AC 131 ms
55,660 KB
testcase_26 AC 132 ms
55,504 KB
testcase_27 AC 130 ms
55,704 KB
testcase_28 AC 131 ms
55,752 KB
testcase_29 AC 132 ms
56,004 KB
testcase_30 AC 136 ms
55,756 KB
testcase_31 AC 133 ms
55,420 KB
testcase_32 TLE -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main{
	
	static final Scanner	s	=new Scanner(System.in);
	
	static final int		mod	=1000000007;
	
	public static void main(String[] __){
		long l=1, base=1000000006/*getBase()*/, n=s.nextLong();
		{
			long buf=base, m=n/mod;
			while(m!=0){
				if(m%2==1){
					l*=buf;
					l%=mod;
				}
				buf*=buf;
				buf%=mod;
				
				m/=2;
			}
		}
		for(long i=n%mod; i>1; i--){
			l*=i;
			l%=mod;
		}
		System.out.println(l);
	}
	
	static int getBase(){
		long base=1;
		for(int i=2; i<mod; i++){
			base*=i;
			base%=mod;
		}
		return (int)base;
	}
}
0