結果

問題 No.502 階乗を計算するだけ
ユーザー りあんりあん
提出日時 2017-04-07 22:46:37
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 28,823 bytes
コンパイル時間 1,060 ms
コンパイル使用メモリ 121,912 KB
実行使用メモリ 27,484 KB
最終ジャッジ日時 2024-07-16 02:43:46
合計ジャッジ時間 3,710 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 24 ms
25,576 KB
testcase_01 AC 27 ms
25,184 KB
testcase_02 AC 26 ms
27,484 KB
testcase_03 AC 25 ms
27,120 KB
testcase_04 AC 26 ms
25,184 KB
testcase_05 AC 26 ms
25,056 KB
testcase_06 AC 25 ms
25,396 KB
testcase_07 AC 26 ms
27,224 KB
testcase_08 AC 24 ms
25,188 KB
testcase_09 AC 25 ms
24,944 KB
testcase_10 AC 24 ms
23,088 KB
testcase_11 AC 25 ms
25,132 KB
testcase_12 AC 24 ms
25,196 KB
testcase_13 AC 25 ms
25,308 KB
testcase_14 AC 24 ms
25,004 KB
testcase_15 AC 24 ms
25,064 KB
testcase_16 AC 24 ms
27,348 KB
testcase_17 AC 25 ms
25,444 KB
testcase_18 AC 25 ms
25,264 KB
testcase_19 AC 25 ms
25,140 KB
testcase_20 AC 24 ms
27,120 KB
testcase_21 AC 25 ms
25,184 KB
testcase_22 AC 40 ms
27,104 KB
testcase_23 AC 30 ms
25,192 KB
testcase_24 AC 35 ms
25,060 KB
testcase_25 AC 26 ms
25,136 KB
testcase_26 AC 33 ms
25,180 KB
testcase_27 AC 29 ms
25,516 KB
testcase_28 AC 30 ms
27,108 KB
testcase_29 AC 27 ms
25,316 KB
testcase_30 AC 38 ms
24,808 KB
testcase_31 AC 30 ms
25,324 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 26 ms
25,052 KB
testcase_43 AC 25 ms
26,852 KB
testcase_44 AC 26 ms
25,184 KB
testcase_45 AC 25 ms
27,108 KB
testcase_46 AC 25 ms
27,220 KB
testcase_47 AC 25 ms
24,684 KB
testcase_48 AC 26 ms
22,828 KB
testcase_49 AC 25 ms
25,140 KB
testcase_50 AC 26 ms
24,808 KB
testcase_51 AC 26 ms
25,056 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.IO;
using System.Text;
using System.Diagnostics;

using Binary = System.Func<System.Linq.Expressions.ParameterExpression, System.Linq.Expressions.ParameterExpression, System.Linq.Expressions.BinaryExpression>;
using Unary = System.Func<System.Linq.Expressions.ParameterExpression, System.Linq.Expressions.UnaryExpression>;

class Program
{
    static StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
    static Scan sc = new Scan();
//    static Scan sc = new ScanCHK();
    const int M = 1000000007;
    const double eps = 1e-9;
    static readonly int[] dd = { 0, 1, 0, -1, 0 };
    static void Main()
    {
        var n = sc.Long;
        if (n >= M)
        {
            DBG(0);
            return;
        }
        var a = new int[1001];
a[0] = 1;
a[1] = 641102369;
a[2] = 578095319;
a[3] = 5832229;
a[4] = 259081142;
a[5] = 974067448;
a[6] = 316220877;
a[7] = 690120224;
a[8] = 251368199;
a[9] = 980250487;
a[10] = 682498929;
a[11] = 134623568;
a[12] = 95936601;
a[13] = 933097914;
a[14] = 167332441;
a[15] = 598816162;
a[16] = 336060741;
a[17] = 248744620;
a[18] = 626497524;
a[19] = 288843364;
a[20] = 491101308;
a[21] = 245341950;
a[22] = 565768255;
a[23] = 246899319;
a[24] = 968999;
a[25] = 586350670;
a[26] = 638587686;
a[27] = 881746146;
a[28] = 19426633;
a[29] = 850500036;
a[30] = 76479948;
a[31] = 268124147;
a[32] = 842267748;
a[33] = 886294336;
a[34] = 485348706;
a[35] = 463847391;
a[36] = 544075857;
a[37] = 898187927;
a[38] = 798967520;
a[39] = 82926604;
a[40] = 723816384;
a[41] = 156530778;
a[42] = 721996174;
a[43] = 299085602;
a[44] = 323604647;
a[45] = 172827403;
a[46] = 398699886;
a[47] = 530389102;
a[48] = 294587621;
a[49] = 813805606;
a[50] = 67347853;
a[51] = 497478507;
a[52] = 196447201;
a[53] = 722054885;
a[54] = 228338256;
a[55] = 407719831;
a[56] = 762479457;
a[57] = 746536789;
a[58] = 811667359;
a[59] = 778773518;
a[60] = 27368307;
a[61] = 438371670;
a[62] = 59469516;
a[63] = 5974669;
a[64] = 766196482;
a[65] = 606322308;
a[66] = 86609485;
a[67] = 889750731;
a[68] = 340941507;
a[69] = 371263376;
a[70] = 625544428;
a[71] = 788878910;
a[72] = 808412394;
a[73] = 996952918;
a[74] = 585237443;
a[75] = 1669644;
a[76] = 361786913;
a[77] = 480748381;
a[78] = 595143852;
a[79] = 837229828;
a[80] = 199888908;
a[81] = 526807168;
a[82] = 579691190;
a[83] = 145404005;
a[84] = 459188207;
a[85] = 534491822;
a[86] = 439729802;
a[87] = 840398449;
a[88] = 899297830;
a[89] = 235861787;
a[90] = 888050723;
a[91] = 656116726;
a[92] = 736550105;
a[93] = 440902696;
a[94] = 85990869;
a[95] = 884343068;
a[96] = 56305184;
a[97] = 973478770;
a[98] = 168891766;
a[99] = 804805577;
a[100] = 927880474;
a[101] = 876297919;
a[102] = 934814019;
a[103] = 676405347;
a[104] = 567277637;
a[105] = 112249297;
a[106] = 44930135;
a[107] = 39417871;
a[108] = 47401357;
a[109] = 108819476;
a[110] = 281863274;
a[111] = 60168088;
a[112] = 692636218;
a[113] = 432775082;
a[114] = 14235602;
a[115] = 770511792;
a[116] = 400295761;
a[117] = 697066277;
a[118] = 421835306;
a[119] = 220108638;
a[120] = 661224977;
a[121] = 261799937;
a[122] = 168203998;
a[123] = 802214249;
a[124] = 544064410;
a[125] = 935080803;
a[126] = 583967898;
a[127] = 211768084;
a[128] = 751231582;
a[129] = 972424306;
a[130] = 623534362;
a[131] = 335160196;
a[132] = 243276029;
a[133] = 554749550;
a[134] = 60050552;
a[135] = 797848181;
a[136] = 395891998;
a[137] = 172428290;
a[138] = 159554990;
a[139] = 887420150;
a[140] = 970055531;
a[141] = 250388809;
a[142] = 487998999;
a[143] = 856259313;
a[144] = 82104855;
a[145] = 232253360;
a[146] = 513365505;
a[147] = 244109365;
a[148] = 1559745;
a[149] = 695345956;
a[150] = 261384175;
a[151] = 849009131;
a[152] = 323214113;
a[153] = 747664143;
a[154] = 444090941;
a[155] = 659224434;
a[156] = 80729842;
a[157] = 570033864;
a[158] = 664989237;
a[159] = 827348878;
a[160] = 195888993;
a[161] = 576798521;
a[162] = 457882808;
a[163] = 731551699;
a[164] = 212938473;
a[165] = 509096183;
a[166] = 827544702;
a[167] = 678320208;
a[168] = 677711203;
a[169] = 289752035;
a[170] = 66404266;
a[171] = 555972231;
a[172] = 195290384;
a[173] = 97136305;
a[174] = 349551356;
a[175] = 785113347;
a[176] = 83489485;
a[177] = 66247239;
a[178] = 52167191;
a[179] = 307390891;
a[180] = 547665832;
a[181] = 143066173;
a[182] = 350016754;
a[183] = 917404120;
a[184] = 296269301;
a[185] = 996122673;
a[186] = 23015220;
a[187] = 602139210;
a[188] = 748566338;
a[189] = 187348575;
a[190] = 109838563;
a[191] = 574053420;
a[192] = 105574531;
a[193] = 304173654;
a[194] = 542432219;
a[195] = 34538816;
a[196] = 325636655;
a[197] = 437843114;
a[198] = 630621321;
a[199] = 26853683;
a[200] = 933245637;
a[201] = 616368450;
a[202] = 238971581;
a[203] = 511371690;
a[204] = 557301633;
a[205] = 911398531;
a[206] = 848952161;
a[207] = 958992544;
a[208] = 925152039;
a[209] = 914456118;
a[210] = 724691727;
a[211] = 636817583;
a[212] = 238087006;
a[213] = 946237212;
a[214] = 910291942;
a[215] = 114985663;
a[216] = 492237273;
a[217] = 450387329;
a[218] = 834860913;
a[219] = 763017204;
a[220] = 368925948;
a[221] = 475812562;
a[222] = 740594930;
a[223] = 45060610;
a[224] = 806047532;
a[225] = 464456846;
a[226] = 172115341;
a[227] = 75307702;
a[228] = 116261993;
a[229] = 562519302;
a[230] = 268838846;
a[231] = 173784895;
a[232] = 243624360;
a[233] = 61570384;
a[234] = 481661251;
a[235] = 938269070;
a[236] = 95182730;
a[237] = 91068149;
a[238] = 115435332;
a[239] = 495022305;
a[240] = 136026497;
a[241] = 506496856;
a[242] = 710729672;
a[243] = 113570024;
a[244] = 366384665;
a[245] = 564758715;
a[246] = 270239666;
a[247] = 277118392;
a[248] = 79874094;
a[249] = 702807165;
a[250] = 112390913;
a[251] = 730341625;
a[252] = 103056890;
a[253] = 677948390;
a[254] = 339464594;
a[255] = 167240465;
a[256] = 108312174;
a[257] = 839079953;
a[258] = 479334442;
a[259] = 271788964;
a[260] = 135498044;
a[261] = 277717575;
a[262] = 591048681;
a[263] = 811637561;
a[264] = 353339603;
a[265] = 889410460;
a[266] = 839849206;
a[267] = 192345193;
a[268] = 736265527;
a[269] = 316439118;
a[270] = 217544623;
a[271] = 788132977;
a[272] = 618898635;
a[273] = 183011467;
a[274] = 380858207;
a[275] = 996097969;
a[276] = 898554793;
a[277] = 335353644;
a[278] = 54062950;
a[279] = 611251733;
a[280] = 419363534;
a[281] = 965429853;
a[282] = 160398980;
a[283] = 151319402;
a[284] = 990918946;
a[285] = 607730875;
a[286] = 450718279;
a[287] = 173539388;
a[288] = 648991369;
a[289] = 970937898;
a[290] = 500780548;
a[291] = 780122909;
a[292] = 39052406;
a[293] = 276894233;
a[294] = 460373282;
a[295] = 651081062;
a[296] = 461415770;
a[297] = 358700839;
a[298] = 643638805;
a[299] = 560006119;
a[300] = 668123525;
a[301] = 686692315;
a[302] = 673464765;
a[303] = 957633609;
a[304] = 199866123;
a[305] = 563432246;
a[306] = 841799766;
a[307] = 385330357;
a[308] = 504962686;
a[309] = 954061253;
a[310] = 128487469;
a[311] = 685707545;
a[312] = 299172297;
a[313] = 717975101;
a[314] = 577786541;
a[315] = 318951960;
a[316] = 773206631;
a[317] = 306832604;
a[318] = 204355779;
a[319] = 573592106;
a[320] = 30977140;
a[321] = 450398100;
a[322] = 363172638;
a[323] = 258379324;
a[324] = 472935553;
a[325] = 93940075;
a[326] = 587220627;
a[327] = 776264326;
a[328] = 793270300;
a[329] = 291733496;
a[330] = 522049725;
a[331] = 579995261;
a[332] = 335416359;
a[333] = 142946099;
a[334] = 472012302;
a[335] = 559947225;
a[336] = 332139472;
a[337] = 499377092;
a[338] = 464599136;
a[339] = 164752359;
a[340] = 309058615;
a[341] = 86117128;
a[342] = 580204973;
a[343] = 563781682;
a[344] = 954840109;
a[345] = 624577416;
a[346] = 895609896;
a[347] = 888287558;
a[348] = 836813268;
a[349] = 926036911;
a[350] = 386027524;
a[351] = 184419613;
a[352] = 724205533;
a[353] = 403351886;
a[354] = 715247054;
a[355] = 716986954;
a[356] = 830567832;
a[357] = 383388563;
a[358] = 68409439;
a[359] = 6734065;
a[360] = 189239124;
a[361] = 68322490;
a[362] = 943653305;
a[363] = 405755338;
a[364] = 811056092;
a[365] = 179518046;
a[366] = 825132993;
a[367] = 343807435;
a[368] = 985084650;
a[369] = 868553027;
a[370] = 148528617;
a[371] = 160684257;
a[372] = 882148737;
a[373] = 591915968;
a[374] = 701445829;
a[375] = 529726489;
a[376] = 302177126;
a[377] = 974886682;
a[378] = 241107368;
a[379] = 798830099;
a[380] = 940567523;
a[381] = 11633075;
a[382] = 325334066;
a[383] = 346091869;
a[384] = 115312728;
a[385] = 473718967;
a[386] = 218129285;
a[387] = 878471898;
a[388] = 180002392;
a[389] = 699739374;
a[390] = 917084264;
a[391] = 856859395;
a[392] = 435327356;
a[393] = 808651347;
a[394] = 421623838;
a[395] = 105419548;
a[396] = 59883031;
a[397] = 322487421;
a[398] = 79716267;
a[399] = 715317963;
a[400] = 429277690;
a[401] = 398078032;
a[402] = 316486674;
a[403] = 384843585;
a[404] = 940338439;
a[405] = 937409008;
a[406] = 940524812;
a[407] = 947549662;
a[408] = 833550543;
a[409] = 593524514;
a[410] = 996164327;
a[411] = 987314628;
a[412] = 697611981;
a[413] = 636177449;
a[414] = 274192146;
a[415] = 418537348;
a[416] = 925347821;
a[417] = 952831975;
a[418] = 893732627;
a[419] = 1277567;
a[420] = 358655417;
a[421] = 141866945;
a[422] = 581830879;
a[423] = 987597705;
a[424] = 347046911;
a[425] = 775305697;
a[426] = 125354499;
a[427] = 951540811;
a[428] = 247662371;
a[429] = 343043237;
a[430] = 568392357;
a[431] = 997474832;
a[432] = 209244402;
a[433] = 380480118;
a[434] = 149586983;
a[435] = 392838702;
a[436] = 309134554;
a[437] = 990779998;
a[438] = 263053337;
a[439] = 325362513;
a[440] = 780072518;
a[441] = 551028176;
a[442] = 990826116;
a[443] = 989944961;
a[444] = 155569943;
a[445] = 596737944;
a[446] = 711553356;
a[447] = 268844715;
a[448] = 451373308;
a[449] = 379404150;
a[450] = 462639908;
a[451] = 961812918;
a[452] = 654611901;
a[453] = 382776490;
a[454] = 41815820;
a[455] = 843321396;
a[456] = 675258797;
a[457] = 845583555;
a[458] = 934281721;
a[459] = 741114145;
a[460] = 275105629;
a[461] = 666247477;
a[462] = 325912072;
a[463] = 526131620;
a[464] = 252551589;
a[465] = 432030917;
a[466] = 554917439;
a[467] = 818036959;
a[468] = 754363835;
a[469] = 795190182;
a[470] = 909210595;
a[471] = 278704903;
a[472] = 719566487;
a[473] = 628514947;
a[474] = 424989675;
a[475] = 321685608;
a[476] = 50590510;
a[477] = 832069712;
a[478] = 198768464;
a[479] = 702004730;
a[480] = 99199382;
a[481] = 707469729;
a[482] = 747407118;
a[483] = 302020341;
a[484] = 497196934;
a[485] = 5003231;
a[486] = 726997875;
a[487] = 382617671;
a[488] = 296229203;
a[489] = 183888367;
a[490] = 703397904;
a[491] = 552133875;
a[492] = 732868367;
a[493] = 350095207;
a[494] = 26031303;
a[495] = 863250534;
a[496] = 216665960;
a[497] = 561745549;
a[498] = 352946234;
a[499] = 784139777;
a[500] = 733333339;
a[501] = 503105966;
a[502] = 459878625;
a[503] = 803187381;
a[504] = 16634739;
a[505] = 180898306;
a[506] = 68718097;
a[507] = 985594252;
a[508] = 404206040;
a[509] = 749724532;
a[510] = 97830135;
a[511] = 611751357;
a[512] = 31131935;
a[513] = 662741752;
a[514] = 864326453;
a[515] = 864869025;
a[516] = 167831173;
a[517] = 559214642;
a[518] = 718498895;
a[519] = 91352335;
a[520] = 608823837;
a[521] = 473379392;
a[522] = 385388084;
a[523] = 152267158;
a[524] = 681756977;
a[525] = 46819124;
a[526] = 313132653;
a[527] = 56547945;
a[528] = 442795120;
a[529] = 796616594;
a[530] = 256141983;
a[531] = 152028387;
a[532] = 636578562;
a[533] = 385377759;
a[534] = 553033642;
a[535] = 491415383;
a[536] = 919273670;
a[537] = 996049638;
a[538] = 326686486;
a[539] = 160150665;
a[540] = 141827977;
a[541] = 540818053;
a[542] = 693305776;
a[543] = 593938674;
a[544] = 186576440;
a[545] = 688809790;
a[546] = 565456578;
a[547] = 749296077;
a[548] = 519397500;
a[549] = 551096742;
a[550] = 696628828;
a[551] = 775025061;
a[552] = 370732451;
a[553] = 164246193;
a[554] = 915265013;
a[555] = 457469634;
a[556] = 923043932;
a[557] = 912368644;
a[558] = 777901604;
a[559] = 464118005;
a[560] = 637939935;
a[561] = 956856710;
a[562] = 490676632;
a[563] = 453019482;
a[564] = 462528877;
a[565] = 502297454;
a[566] = 798895521;
a[567] = 100498586;
a[568] = 699767918;
a[569] = 849974789;
a[570] = 811575797;
a[571] = 438952959;
a[572] = 606870929;
a[573] = 907720182;
a[574] = 179111720;
a[575] = 48053248;
a[576] = 508038818;
a[577] = 811944661;
a[578] = 752550134;
a[579] = 401382061;
a[580] = 848924691;
a[581] = 764368449;
a[582] = 34629406;
a[583] = 529840945;
a[584] = 435904287;
a[585] = 26011548;
a[586] = 208184231;
a[587] = 446477394;
a[588] = 206330671;
a[589] = 366033520;
a[590] = 131772368;
a[591] = 185646898;
a[592] = 648711554;
a[593] = 472759660;
a[594] = 523696723;
a[595] = 271198437;
a[596] = 25058942;
a[597] = 859369491;
a[598] = 817928963;
a[599] = 330711333;
a[600] = 724464507;
a[601] = 437605233;
a[602] = 701453022;
a[603] = 626663115;
a[604] = 281230685;
a[605] = 510650790;
a[606] = 596949867;
a[607] = 295726547;
a[608] = 303076380;
a[609] = 465070856;
a[610] = 272814771;
a[611] = 538771609;
a[612] = 48824684;
a[613] = 951279549;
a[614] = 939889684;
a[615] = 564188856;
a[616] = 48527183;
a[617] = 201307702;
a[618] = 484458461;
a[619] = 861754542;
a[620] = 326159309;
a[621] = 181594759;
a[622] = 668422905;
a[623] = 286273596;
a[624] = 965656187;
a[625] = 44135644;
a[626] = 359960756;
a[627] = 936229527;
a[628] = 407934361;
a[629] = 267193060;
a[630] = 456152084;
a[631] = 459116722;
a[632] = 124804049;
a[633] = 262322489;
a[634] = 920251227;
a[635] = 816929577;
a[636] = 483924582;
a[637] = 151834896;
a[638] = 167087470;
a[639] = 490222511;
a[640] = 903466878;
a[641] = 361583925;
a[642] = 368114731;
a[643] = 339383292;
a[644] = 388728584;
a[645] = 218107212;
a[646] = 249153339;
a[647] = 909458706;
a[648] = 322908524;
a[649] = 202649964;
a[650] = 92255682;
a[651] = 573074791;
a[652] = 15570863;
a[653] = 94331513;
a[654] = 744158074;
a[655] = 196345098;
a[656] = 334326205;
a[657] = 9416035;
a[658] = 98349682;
a[659] = 882121662;
a[660] = 769795511;
a[661] = 231988936;
a[662] = 888146074;
a[663] = 137603545;
a[664] = 582627184;
a[665] = 407518072;
a[666] = 919419361;
a[667] = 909433461;
a[668] = 986708498;
a[669] = 310317874;
a[670] = 373745190;
a[671] = 263645931;
a[672] = 256853930;
a[673] = 876379959;
a[674] = 702823274;
a[675] = 147050765;
a[676] = 308186532;
a[677] = 175504139;
a[678] = 180350107;
a[679] = 797736554;
a[680] = 606241871;
a[681] = 384547635;
a[682] = 273712630;
a[683] = 586444655;
a[684] = 682189174;
a[685] = 666493603;
a[686] = 946867127;
a[687] = 819114541;
a[688] = 502371023;
a[689] = 261970285;
a[690] = 825871994;
a[691] = 126925175;
a[692] = 701506133;
a[693] = 314738056;
a[694] = 341779962;
a[695] = 561011609;
a[696] = 815463367;
a[697] = 46765164;
a[698] = 49187570;
a[699] = 188054995;
a[700] = 957939114;
a[701] = 64814326;
a[702] = 933376898;
a[703] = 329837066;
a[704] = 338121343;
a[705] = 765215899;
a[706] = 869630152;
a[707] = 978119194;
a[708] = 632627667;
a[709] = 975266085;
a[710] = 435887178;
a[711] = 282092463;
a[712] = 129621197;
a[713] = 758245605;
a[714] = 827722926;
a[715] = 201339230;
a[716] = 918513230;
a[717] = 322096036;
a[718] = 547838438;
a[719] = 985546115;
a[720] = 852304035;
a[721] = 593090119;
a[722] = 689189630;
a[723] = 555842733;
a[724] = 567033437;
a[725] = 469928208;
a[726] = 212842957;
a[727] = 117842065;
a[728] = 404149413;
a[729] = 155133422;
a[730] = 663307737;
a[731] = 208761293;
a[732] = 206282795;
a[733] = 717946122;
a[734] = 488906585;
a[735] = 414236650;
a[736] = 280700600;
a[737] = 962670136;
a[738] = 534279149;
a[739] = 214569244;
a[740] = 375297772;
a[741] = 811053196;
a[742] = 922377372;
a[743] = 289594327;
a[744] = 219932130;
a[745] = 211487466;
a[746] = 701050258;
a[747] = 398782410;
a[748] = 863002719;
a[749] = 27236531;
a[750] = 217598709;
a[751] = 375472836;
a[752] = 810551911;
a[753] = 178598958;
a[754] = 247844667;
a[755] = 676526196;
a[756] = 812283640;
a[757] = 863066876;
a[758] = 857241854;
a[759] = 113917835;
a[760] = 624148346;
a[761] = 726089763;
a[762] = 564827277;
a[763] = 826300950;
a[764] = 478982047;
a[765] = 439411911;
a[766] = 454039189;
a[767] = 633292726;
a[768] = 48562889;
a[769] = 802100365;
a[770] = 671734977;
a[771] = 945204804;
a[772] = 508831870;
a[773] = 398781902;
a[774] = 897162044;
a[775] = 644050694;
a[776] = 892168027;
a[777] = 828883117;
a[778] = 277714559;
a[779] = 713448377;
a[780] = 624500515;
a[781] = 590098114;
a[782] = 808691930;
a[783] = 514359662;
a[784] = 895205045;
a[785] = 715264908;
a[786] = 628829100;
a[787] = 484492064;
a[788] = 919717789;
a[789] = 513196123;
a[790] = 748510389;
a[791] = 403652653;
a[792] = 574455974;
a[793] = 77123823;
a[794] = 172096141;
a[795] = 819801784;
a[796] = 581418893;
a[797] = 15655126;
a[798] = 15391652;
a[799] = 875641535;
a[800] = 203191898;
a[801] = 264582598;
a[802] = 880691101;
a[803] = 907800444;
a[804] = 986598821;
a[805] = 340030191;
a[806] = 264688936;
a[807] = 369832433;
a[808] = 785804644;
a[809] = 842065079;
a[810] = 423951674;
a[811] = 663560047;
a[812] = 696623384;
a[813] = 496709826;
a[814] = 161960209;
a[815] = 331910086;
a[816] = 541120825;
a[817] = 951524114;
a[818] = 841656666;
a[819] = 162683802;
a[820] = 629786193;
a[821] = 190395535;
a[822] = 269571439;
a[823] = 832671304;
a[824] = 76770272;
a[825] = 341080135;
a[826] = 421943723;
a[827] = 494210290;
a[828] = 751040886;
a[829] = 317076664;
a[830] = 672850561;
a[831] = 72482816;
a[832] = 493689107;
a[833] = 135625240;
a[834] = 100228913;
a[835] = 684748812;
a[836] = 639655136;
a[837] = 906233141;
a[838] = 929893103;
a[839] = 277813439;
a[840] = 814362881;
a[841] = 562608724;
a[842] = 406024012;
a[843] = 885537778;
a[844] = 10065330;
a[845] = 60625018;
a[846] = 983737173;
a[847] = 60517502;
a[848] = 551060742;
a[849] = 804930491;
a[850] = 823845496;
a[851] = 727416538;
a[852] = 946421040;
a[853] = 678171399;
a[854] = 842203531;
a[855] = 175638827;
a[856] = 894247956;
a[857] = 538609927;
a[858] = 885362182;
a[859] = 946464959;
a[860] = 116667533;
a[861] = 749816133;
a[862] = 241427979;
a[863] = 871117927;
a[864] = 281804989;
a[865] = 163928347;
a[866] = 563796647;
a[867] = 640266394;
a[868] = 774625892;
a[869] = 59342705;
a[870] = 256473217;
a[871] = 674115061;
a[872] = 918860977;
a[873] = 322633051;
a[874] = 753513874;
a[875] = 393556719;
a[876] = 304644842;
a[877] = 767372800;
a[878] = 161362528;
a[879] = 754787150;
a[880] = 627655552;
a[881] = 677395736;
a[882] = 799289297;
a[883] = 846650652;
a[884] = 816701166;
a[885] = 687265514;
a[886] = 787113234;
a[887] = 358757251;
a[888] = 701220427;
a[889] = 607715125;
a[890] = 245795606;
a[891] = 600624983;
a[892] = 10475577;
a[893] = 728620948;
a[894] = 759404319;
a[895] = 36292292;
a[896] = 491466901;
a[897] = 22556579;
a[898] = 114495791;
a[899] = 647630109;
a[900] = 586445753;
a[901] = 482254337;
a[902] = 718623833;
a[903] = 763514207;
a[904] = 66547751;
a[905] = 953634340;
a[906] = 351472920;
a[907] = 308474522;
a[908] = 494166907;
a[909] = 634359666;
a[910] = 172114298;
a[911] = 865440961;
a[912] = 364380585;
a[913] = 921648059;
a[914] = 965683742;
a[915] = 260466949;
a[916] = 117483873;
a[917] = 962540888;
a[918] = 237120480;
a[919] = 620531822;
a[920] = 193781724;
a[921] = 213092254;
a[922] = 107141741;
a[923] = 602742426;
a[924] = 793307102;
a[925] = 756154604;
a[926] = 236455213;
a[927] = 362928234;
a[928] = 14162538;
a[929] = 753042874;
a[930] = 778983779;
a[931] = 25977209;
a[932] = 49389215;
a[933] = 698308420;
a[934] = 859637374;
a[935] = 49031023;
a[936] = 713258160;
a[937] = 737331920;
a[938] = 923333660;
a[939] = 804861409;
a[940] = 83868974;
a[941] = 682873215;
a[942] = 217298111;
a[943] = 883278906;
a[944] = 176966527;
a[945] = 954913;
a[946] = 105359006;
a[947] = 390019735;
a[948] = 10430738;
a[949] = 706334445;
a[950] = 315103615;
a[951] = 567473423;
a[952] = 708233401;
a[953] = 48160594;
a[954] = 946149627;
a[955] = 346966053;
a[956] = 281329488;
a[957] = 462880311;
a[958] = 31503476;
a[959] = 185438078;
a[960] = 965785236;
a[961] = 992656683;
a[962] = 916291845;
a[963] = 881482632;
a[964] = 899946391;
a[965] = 321900901;
a[966] = 512634493;
a[967] = 303338827;
a[968] = 121000338;
a[969] = 967284733;
a[970] = 492741665;
a[971] = 152233223;
a[972] = 165393390;
a[973] = 680128316;
a[974] = 917041303;
a[975] = 532702135;
a[976] = 741626808;
a[977] = 496442755;
a[978] = 536841269;
a[979] = 131384366;
a[980] = 377329025;
a[981] = 301196854;
a[982] = 859917803;
a[983] = 676511002;
a[984] = 373451745;
a[985] = 847645126;
a[986] = 823495900;
a[987] = 576368335;
a[988] = 73146164;
a[989] = 954958912;
a[990] = 847549272;
a[991] = 241289571;
a[992] = 646654592;
a[993] = 216046746;
a[994] = 205951465;
a[995] = 3258987;
a[996] = 780882948;
a[997] = 822439091;
a[998] = 598245292;
a[999] = 869544707;
a[1000] = 698611116;
        long ans = a[n / 1000000];
        for (long i = Math.Max(n / 1000000 * 1000000, 1); i <= n; i++)
        {
            ans = ans * i % M;
        }
        Prt(ans);
        sw.Flush();
    }

    static void swap<T>(ref T a, ref T b) { var t = a; a = b; b = t; }
    static T Max<T>(params T[] a) { return a.Max(); }
    static T Min<T>(params T[] a) { return a.Min(); }
    static void DBG(string a) { Console.WriteLine(a); }
    static void DBG<T>(IEnumerable<T> a) { Console.WriteLine(string.Join(" ", a)); }
    static void DBG(params object[] a) { Console.WriteLine(string.Join(" ", a)); }
    static void Prt(string a) { sw.WriteLine(a); }
    static void Prt<T>(IEnumerable<T> a) { sw.WriteLine(string.Join(" ", a)); }
    static void Prt(params object[] a) { sw.WriteLine(string.Join(" ", a)); }
}
static class ex
{
    public static void swap<T>(this IList<T> a, int i, int j) { var t = a[i]; a[i] = a[j]; a[j] = t; }
    public static T[] copy<T>(this IList<T> a)
    {
        var ret = new T[a.Count];
        for (int i = 0; i < a.Count; i++) ret[i] = a[i];
        return ret;
    }
}
static class Operator<T>
{
    static readonly ParameterExpression x = Expression.Parameter(typeof(T), "x");
    static readonly ParameterExpression y = Expression.Parameter(typeof(T), "y");
    public static readonly Func<T, T, T> Add = Lambda(Expression.Add);
    public static readonly Func<T, T, T> Subtract = Lambda(Expression.Subtract);
    public static readonly Func<T, T, T> Multiply = Lambda(Expression.Multiply);
    public static readonly Func<T, T, T> Divide = Lambda(Expression.Divide);
    public static readonly Func<T, T> Plus = Lambda(Expression.UnaryPlus);
    public static readonly Func<T, T> Negate = Lambda(Expression.Negate);
    public static Func<T, T, T> Lambda(Binary op) { return Expression.Lambda<Func<T, T, T>>(op(x, y), x, y).Compile(); }
    public static Func<T, T> Lambda(Unary op) { return Expression.Lambda<Func<T, T>>(op(x), x).Compile(); }
}

class ScanCHK : Scan
{
    public new string Str { get { var s = Console.ReadLine(); if (s != s.Trim()) throw new Exception(); return s; } }
}
class Scan
{
    public int Int { get { return int.Parse(Str); } }
    public long Long { get { return long.Parse(Str); } }
    public double Double { get { return double.Parse(Str); } }
    public string Str { get { return Console.ReadLine().Trim(); } }
    public int[] IntArr { get { return StrArr.Select(int.Parse).ToArray(); } }
    public long[] LongArr { get { return StrArr.Select(long.Parse).ToArray(); } }
    public double[] DoubleArr { get { return StrArr.Select(double.Parse).ToArray(); } }
    public string[] StrArr { get { return Str.Split(); } }
    bool eq<T, U>() { return typeof(T).Equals(typeof(U)); }
    T ct<T, U>(U a) { return (T)Convert.ChangeType(a, typeof(T)); }
    T cv<T>(string s) { return eq<T, int>()    ? ct<T, int>(int.Parse(s))
                             : eq<T, long>()   ? ct<T, long>(long.Parse(s))
                             : eq<T, double>() ? ct<T, double>(double.Parse(s))
                             : eq<T, char>()   ? ct<T, char>(s[0])
                                               : ct<T, string>(s); }
    public void Multi<T>(out T a) { a = cv<T>(Str); }
    public void Multi<T, U>(out T a, out U b)
    { var ar = StrArr; a = cv<T>(ar[0]); b = cv<U>(ar[1]); }
    public void Multi<T, U, V>(out T a, out U b, out V c)
    { var ar = StrArr; a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); }
    public void Multi<T, U, V, W>(out T a, out U b, out V c, out W d)
    { var ar = StrArr; a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); }
    public void Multi<T, U, V, W, X>(out T a, out U b, out V c, out W d, out X e)
    { var ar = StrArr; a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); e = cv<X>(ar[4]); }
}
class mymath
{
    public static long Mod = 1000000007;
    public static bool isprime(long a)
    {
        if (a < 2) return false;
        for (long i = 2; i * i <= a; i++) if (a % i == 0) return false;
        return true;
    }
    public static bool[] sieve(int n)
    {
        var p = new bool[n + 1];
        for (int i = 2; i <= n; i++) p[i] = true;
        for (int i = 2; i * i <= n; i++) if (p[i]) for (int j = i * i; j <= n; j += i) p[j] = false;
        return p;
    }
    public static List<int> getprimes(int n)
    {
        var prs = new List<int>();
        var p = sieve(n);
        for (int i = 2; i <= n; i++) if (p[i]) prs.Add(i);
        return prs;
    }
    public static long[][] E(int n)
    {
        var ret = new long[n][];
        for (int i = 0; i < n; i++) { ret[i] = new long[n]; ret[i][i] = 1; }
        return ret;
    }
    public static long[][] pow(long[][] A, long n)
    {
        if (n == 0) return E(A.Length);
        var t = pow(A, n / 2);
        if ((n & 1) == 0) return mul(t, t);
        return mul(mul(t, t), A);
    }
    public static double dot(double[] x, double[] y)
    {
        int n = x.Length;
        double ret = 0;
        for (int i = 0; i < n; i++) ret += x[i] * y[i];
        return ret;
    }
    public static long dot(long[] x, long[] y)
    {
        int n = x.Length;
        long ret = 0;
        for (int i = 0; i < n; i++) ret = (ret + x[i] * y[i]) % Mod;
        return ret;
    }
    public static T[][] trans<T>(T[][] A)
    {
        int n = A[0].Length, m = A.Length;
        var ret = new T[n][];
        for (int i = 0; i < n; i++) { ret[i] = new T[m]; for (int j = 0; j < m; j++) ret[i][j] = A[j][i]; }
        return ret;
    }
    public static double[] mul(double[][] A, double[] x)
    {
        int n = A.Length;
        var ret = new double[n];
        for (int i = 0; i < n; i++) ret[i] = dot(x, A[i]);
        return ret;
    }
    public static long[] mul(long[][] A, long[] x)
    {
        int n = A.Length;
        var ret = new long[n];
        for (int i = 0; i < n; i++) ret[i] = dot(x, A[i]);
        return ret;
    }
    public static long[][] mul(long[][] A, long[][] B)
    {
        int n = A.Length;
        var Bt = trans(B);
        var ret = new long[n][];
        for (int i = 0; i < n; i++) ret[i] = mul(Bt, A[i]);
        return ret;
    }
    public static long[] add(long[] x, long[] y)
    {
        int n = x.Length;
        var ret = new long[n];
        for (int i = 0; i < n; i++) ret[i] = (x[i] + y[i]) % Mod;
        return ret;
    }
    public static long[][] add(long[][] A, long[][] B)
    {
        int n = A.Length;
        var ret = new long[n][];
        for (int i = 0; i < n; i++) ret[i] = add(A[i], B[i]);
        return ret;
    }
    public static long pow(long a, long b)
    {
        if (a >= Mod) return pow(a % Mod, b);
        if (a == 0) return 0;
        if (b == 0) return 1;
        var t = pow(a, b / 2);
        if ((b & 1) == 0) return t * t % Mod;
        return t * t % Mod * a % Mod;
    }
    public static long inv(long a) { return pow(a, Mod - 2); }
    public static long gcd(long a, long b)
    {
        while (b > 0) { var t = a % b; a = b; b = t; }
        return a;
    }
    // a x + b y = gcd(a, b)
    public static long extgcd(long a, long b, out long x, out long y)
    {
        long g = a; x = 1; y = 0;
        if (b > 0) { g = extgcd(b, a % b, out y, out x); y -= a / b * x; }
        return g;
    }
    public static long lcm(long a, long b) { return a / gcd(a, b) * b; }
    public static long comb(int n, int r)
    {
        if (n < 0 || r < 0 || r > n) return 0;
        if (n - r < r) r = n - r;
        if (r == 0) return 1;
        if (r == 1) return n;
        int[] numer = new int[r], denom = new int[r];
        for (int k = 0; k < r; k++) { numer[k] = n - r + k + 1; denom[k] = k + 1; }
        for (int p = 2; p <= r; p++)
        {
            int piv = denom[p - 1];
            if (piv > 1)
            {
                int ofst = (n - r) % p;
                for (int k = p - 1; k < r; k += p) { numer[k - ofst] /= piv; denom[k] /= piv; }
            }
        }
        long ret = 1;
        for (int k = 0; k < r; k++) if (numer[k] > 1) ret = ret * numer[k] % Mod;
        return ret;
    }
}
0