結果

問題 No.502 階乗を計算するだけ
ユーザー kotatsugamekotatsugame
提出日時 2022-05-29 02:13:58
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 19 ms / 1,000 ms
コード長 3,966 bytes
コンパイル時間 532 ms
コンパイル使用メモリ 64,528 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-20 23:39:14
合計ジャッジ時間 2,079 ms
ジャッジサーバーID
(参考情報)
judge11 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 1 ms
4,348 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 1 ms
4,348 KB
testcase_19 AC 2 ms
4,348 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 8 ms
4,348 KB
testcase_23 AC 3 ms
4,348 KB
testcase_24 AC 5 ms
4,348 KB
testcase_25 AC 2 ms
4,348 KB
testcase_26 AC 4 ms
4,348 KB
testcase_27 AC 3 ms
4,348 KB
testcase_28 AC 4 ms
4,348 KB
testcase_29 AC 2 ms
4,348 KB
testcase_30 AC 7 ms
4,348 KB
testcase_31 AC 4 ms
4,348 KB
testcase_32 AC 2 ms
4,348 KB
testcase_33 AC 19 ms
4,348 KB
testcase_34 AC 9 ms
4,348 KB
testcase_35 AC 13 ms
4,348 KB
testcase_36 AC 2 ms
4,348 KB
testcase_37 AC 6 ms
4,348 KB
testcase_38 AC 9 ms
4,348 KB
testcase_39 AC 6 ms
4,348 KB
testcase_40 AC 16 ms
4,348 KB
testcase_41 AC 7 ms
4,348 KB
testcase_42 AC 2 ms
4,348 KB
testcase_43 AC 2 ms
4,348 KB
testcase_44 AC 2 ms
4,348 KB
testcase_45 AC 2 ms
4,348 KB
testcase_46 AC 1 ms
4,348 KB
testcase_47 AC 2 ms
4,348 KB
testcase_48 AC 2 ms
4,348 KB
testcase_49 AC 2 ms
4,348 KB
testcase_50 AC 2 ms
4,348 KB
testcase_51 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:351:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
  351 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
using namespace std;
const int mod=1e9+7;
int s[]={1,
5832229,
316220877,
980250487,
95936601,
598816162,
626497524,
245341950,
968999,
881746146,
76479948,
886294336,
544075857,
82926604,
721996174,
172827403,
294587621,
497478507,
228338256,
746536789,
27368307,
5974669,
86609485,
371263376,
808412394,
1669644,
595143852,
526807168,
459188207,
840398449,
888050723,
440902696,
56305184,
804805577,
934814019,
112249297,
47401357,
60168088,
14235602,
697066277,
661224977,
802214249,
583967898,
972424306,
243276029,
797848181,
159554990,
250388809,
82104855,
244109365,
261384175,
747664143,
80729842,
827348878,
457882808,
509096183,
677711203,
555972231,
349551356,
66247239,
547665832,
917404120,
23015220,
187348575,
105574531,
34538816,
630621321,
616368450,
557301633,
958992544,
724691727,
946237212,
492237273,
763017204,
740594930,
464456846,
116261993,
173784895,
481661251,
91068149,
136026497,
113570024,
270239666,
702807165,
103056890,
167240465,
479334442,
277717575,
353339603,
192345193,
217544623,
183011467,
898554793,
611251733,
160398980,
607730875,
648991369,
780122909,
460373282,
358700839,
668123525,
957633609,
841799766,
954061253,
299172297,
318951960,
204355779,
450398100,
472935553,
776264326,
522049725,
142946099,
332139472,
164752359,
580204973,
624577416,
836813268,
184419613,
715247054,
383388563,
189239124,
405755338,
825132993,
868553027,
882148737,
529726489,
241107368,
11633075,
115312728,
878471898,
917084264,
808651347,
59883031,
715317963,
316486674,
937409008,
833550543,
987314628,
274192146,
952831975,
358655417,
987597705,
125354499,
343043237,
209244402,
392838702,
263053337,
551028176,
155569943,
268844715,
462639908,
382776490,
675258797,
741114145,
325912072,
432030917,
754363835,
278704903,
424989675,
832069712,
99199382,
302020341,
726997875,
183888367,
732868367,
863250534,
352946234,
503105966,
16634739,
985594252,
97830135,
662741752,
167831173,
91352335,
385388084,
46819124,
442795120,
152028387,
553033642,
996049638,
141827977,
593938674,
565456578,
551096742,
370732451,
457469634,
777901604,
956856710,
462528877,
100498586,
811575797,
907720182,
508038818,
401382061,
34629406,
26011548,
206330671,
185646898,
523696723,
859369491,
724464507,
626663115,
596949867,
465070856,
48824684,
564188856,
484458461,
181594759,
965656187,
936229527,
456152084,
262322489,
483924582,
490222511,
368114731,
218107212,
322908524,
573074791,
744158074,
9416035,
769795511,
137603545,
919419361,
310317874,
256853930,
147050765,
180350107,
384547635,
682189174,
819114541,
825871994,
314738056,
815463367,
188054995,
933376898,
765215899,
632627667,
282092463,
827722926,
322096036,
852304035,
555842733,
212842957,
155133422,
206282795,
414236650,
534279149,
811053196,
219932130,
398782410,
217598709,
178598958,
812283640,
113917835,
564827277,
439411911,
48562889,
945204804,
897162044,
828883117,
624500515,
514359662,
628829100,
513196123,
574455974,
819801784,
15391652,
264582598,
986598821,
369832433,
423951674,
496709826,
541120825,
162683802,
269571439,
341080135,
751040886,
72482816,
100228913,
906233141,
814362881,
885537778,
983737173,
804930491,
946421040,
175638827,
885362182,
749816133,
281804989,
640266394,
256473217,
322633051,
304644842,
754787150,
799289297,
687265514,
701220427,
600624983,
759404319,
22556579,
586445753,
763514207,
351472920,
634359666,
364380585,
260466949,
237120480,
213092254,
793307102,
362928234,
778983779,
698308420,
713258160,
804861409,
217298111,
954913,
10430738,
567473423,
946149627,
462880311,
965785236,
881482632,
512634493,
967284733,
165393390,
532702135,
536841269,
301196854,
373451745,
576368335,
847549272,
216046746,
780882948,
869544707,};
int fac(long long n)
{
	if(n>=mod)return 0;
	else
	{
		const int m=3e6;
		const int dv=n/m;
		int ans=s[dv];
		const int dvm=dv*m;
		for(int i=1;i<=n-dvm;i++)ans=(long long)ans*(i+dvm)%mod;
		return ans;
	}
}
main()
{
    long long n;
    cin>>n;
    cout<<fac(n)<<endl;
}
0