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