結果

問題 No.523 LED
ユーザー むらためむらため
提出日時 2019-01-25 12:15:52
言語 Nim
(2.0.2)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 10,696 bytes
コンパイル時間 1,874 ms
コンパイル使用メモリ 66,760 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-14 02:45:23
合計ジャッジ時間 2,762 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

proc getchar_unlocked():char {. importc:"getchar_unlocked",header: "<stdio.h>" .}
proc scan(): int =
  while true:
    let k = getchar_unlocked()
    if k < '0': break
    result = 10 * result + k.ord - '0'.ord

const MOD = 1000000007
proc calc(n:int,startIndex:int=0,startVal:int=1): int =
  result = startVal
  for i in (startIndex+1)..n:
    let m = (i * (2 * i - 1)) mod MOD
    result = ( result * m ) mod MOD

if false:
  stdout.write "cached = ["
  var preIndex = 0
  var preVal = 1
  for n in countup(0,1_000_0000,10000):
    preVal = calc(n,preIndex,preVal)
    preIndex = n
    stdout.write(preVal)
    stdout.write(",")
    stdout.flushFile()
  echo "]"
else:
  #                 ~10000    ~20000
  const cached = [1,895580628,103440341,176639020,218579304,10323028,161679646,933030199,778899565,195770664,180884011,134456019,728203727,9139060,419246611,307357340,270979330,248007424,329764236,984516594,13878255,898259854,636987490,843489416,58933830,604238649,804595492,568246880,650431039,268364158,900005126,990391024,730076976,399740501,854144791,441410382,22955391,106071660,7018955,639906729,853605353,541556921,871080208,726159989,467635727,364243453,701294756,80679585,742793923,98086912,230865212,867859395,295389292,898294570,382643536,557554330,720452070,507645410,721610962,15744177,209121881,774734474,839786329,533017631,888212811,62848309,31900691,766380122,458092854,451036792,120818654,458263126,907784725,793016750,216898477,461951733,324042135,303247080,531809195,887049566,956676994,237562110,725273297,57268726,69935265,34005398,961961304,701056809,476946030,526153994,467841998,775466750,579679872,577494706,930839,59884150,135011472,544809268,677583304,91068505,975701239,376847073,475751075,860670239,134097829,455938749,703294580,541830784,25335352,109685844,847743432,761784190,751388974,2281019,4583167,668584420,91048414,740427505,198463346,580399371,899466530,561201822,261302551,838819516,866357019,575724165,526332099,520471400,896258171,759047965,145447437,787129280,309336500,623959393,653042907,378001142,3431983,725801065,811377514,88354373,242667019,785163858,528480816,311313232,802803859,257733209,547444574,766555885,27485367,842623465,544171177,802317317,471166338,821830458,691167974,454315445,222989467,322768428,495011156,512531682,376622923,877831005,72441214,968222538,282106674,570663275,417968662,414961244,843161644,160694544,392351356,532707027,771569325,471800139,817388276,548349623,587884582,431310906,95470242,315533955,925840018,669007144,376706643,104970861,437289053,617718355,960831436,215777263,498750980,185326591,757278130,473235445,475037434,98478496,658109778,518777316,274698362,232377150,467144096,948261976,694465021,95003380,989093687,254694644,39878795,673335606,961887904,263372180,923816787,259691992,548405441,693900034,731122840,963393776,615209512,724507454,203023273,689530504,450736850,363776983,254797077,820162826,301329760,725719364,725823630,176203303,484909110,344263812,575975222,969092991,273550920,220949844,111560802,728983456,314994627,642856034,702692042,907842086,286410835,597462715,243598545,533427825,871566694,641941774,866659895,615550094,628564749,413748735,372119124,655618310,137218344,870633492,108190662,568841712,392858058,844231468,537299791,896755997,353008956,632948206,527573545,185379274,58348809,265931395,903141414,159480083,367309984,848050077,66573240,257723842,43955006,608523887,528772731,368045067,205505081,605637374,618785515,182061578,384812417,296021973,831683565,281655611,812187312,79538576,209082024,118040974,314624611,247920370,277993104,944800412,233207374,561922583,484480687,224793097,85324095,483514500,585673614,875420912,708310119,942208389,819045129,388199994,873927075,782717200,465113409,695887919,447977193,672397794,884941549,909893521,591130296,448537568,567423561,319895657,198155611,970599030,89651223,46717105,905463154,828400818,261250366,344655926,75725099,971442534,534483429,905012706,356203286,166454161,738016230,558151775,993876947,750625025,911718385,467271685,445232848,332681987,387920805,196434590,506791641,78319632,629889511,873628884,202039023,656566903,508796333,904348551,956498966,469314923,612448590,895410751,671458993,755705993,996978198,45682420,690147771,576272387,153771699,85997964,587409845,270640689,975223812,993391535,419165226,94899480,195704903,221922036,304154085,367840925,522987300,283526484,195721297,760538199,612760005,722597819,305085924,843627000,581904579,143314643,145374658,767560691,249761018,307027073,695794333,306427854,225454689,413514724,676227176,130746890,12926032,314392095,803998215,622328747,727678232,738796830,234453043,333599480,34827116,533908138,104121639,240549854,390946736,596730800,873900214,771836332,749263064,113440172,342955187,517157874,900032436,696444153,14630766,729188298,812178624,726131064,565442997,344039597,967189372,536373816,70678379,416602247,499436736,853251111,61789303,762428340,510959051,232506753,616355482,448186240,914484734,848108618,771239815,837569436,570987707,485653000,576301389,515268359,508838361,144000294,986482029,392887409,678604213,780435156,274746575,750971290,935466689,174568470,990174210,144785357,214443256,29645155,897054228,948331261,977581514,20860925,742682206,482646059,356230790,583989522,662764094,897393306,830470160,823643109,512612808,166396191,101692155,633687553,776188402,907386190,812867250,792991651,507851499,440487170,47847325,985197923,173707800,843249630,503255894,700303398,946607872,10459257,328899896,130891739,690704033,858230622,528410419,560344802,56843155,975274324,745982335,899914074,173263275,128405065,270842848,498880193,186768915,69167217,120189382,41324550,78747934,40554290,18892601,763901971,254558094,274946015,898475244,543673524,52681851,681455737,954394590,37717040,411157058,780955958,495907833,912500135,343416134,599650521,651333520,341810695,670273451,637788899,217487314,444342299,215849848,880713510,486061100,950878535,313027246,89544738,142418463,65310504,2414411,976327431,393952211,901064270,942142140,882418322,708037018,512051817,300021193,956639574,159346256,414412843,131939510,861545102,809865657,747695640,346908342,92306386,315395583,654052722,267078443,776305954,875304086,979137717,306960149,190110039,975994204,196841538,514210079,129476838,366089614,666073289,885538777,50086010,125487956,462340458,487348760,894650087,9628043,530234970,719356243,741459270,272914875,815294754,345351338,688252766,223504194,84185543,423231029,241160235,653125247,29990693,515569907,549586199,957324104,377949712,828132193,550062694,38516355,224441567,733307931,948355191,389708099,902602418,471429321,821098056,50141387,215528064,333269763,840625302,778494515,867513407,140704146,829896637,492941597,521079861,311331345,269812350,114795059,891993095,566380989,333897974,794644137,43154077,180306390,203532264,816426472,488449529,865458559,471953149,412830813,810053106,342427264,802590443,128685988,147550637,743380613,624282555,123856103,10879281,812282460,906887650,274016531,165651938,453572090,673688582,906212512,182006319,328627790,990783198,743584310,126863163,427439939,970492483,178628493,814466512,67001343,726568150,765393564,376365261,846309343,983182571,350526543,402012794,183593658,298152870,44973168,430693542,249403755,515376169,346353676,961027110,231300814,950157193,526194390,277322237,303416277,592494392,789911561,994817115,969274324,795751661,566447682,19903657,136429855,675540787,130078068,757913498,336271640,592974682,456219805,151353168,221813710,549269073,566405153,953223763,700707394,398766834,150602003,147032432,222205354,723867792,584481426,777977184,646681003,194577321,496548978,105377370,385764317,813922454,729453757,744194981,299885815,395484082,648218151,587306174,999272462,701349279,121611864,777891674,797047452,114435617,169124204,688671269,579784684,147601508,288533124,654400800,288376964,856721658,661208068,784328296,645136939,387661543,546232102,64054870,627224179,799543257,274944866,740265865,991650878,956665119,264138838,939298366,466873107,210929926,747204507,951529775,473692937,960418768,446107491,563159079,740062166,209013538,985814949,383465160,547122571,258154949,905760699,903688809,467635649,692393504,303296113,281082858,977522616,73550376,926268160,870765097,429922894,198898555,503660241,761586,331384481,113555757,827608959,473806291,159655782,982583389,425183211,283120609,379499494,890748171,342273815,141475341,150316893,457803695,580851675,291903508,835673219,941368331,153137908,658655858,128425068,233969761,299577091,146288039,436547374,609484588,94833141,656767153,412296490,836497545,603375809,649127050,347312087,935143721,642076486,68884246,395895537,651650208,665093464,298635503,874410520,417179796,245913735,329764839,885837398,827195170,847098127,618538497,94529002,138849247,682585031,966299594,786540000,679025228,806634435,349104487,29389736,996724930,682932658,489809814,576842206,699665270,719349814,38241552,483010622,251148939,341080926,816407982,496955257,906099719,539086109,794068532,104530902,996644353,795575816,29899264,867437681,834027364,976826191,805756606,288805787,420461267,406816433,870101912,909182872,593714442,417971458,728636918,556806865,138842281,677887197,794195945,179638950,43880335,798926383,452068312,791059019,662840751,318414918,700784743,953173676,450091572,156212264,646685163,8422870,536852008,561193704,667306635,636921201,591109528,847267524,999506054,357175419,838231371,549801960,572191055,435926354,517772600,197866435,192635771,695480738,41120417,660361160,679389703,903606576,931846039,33609374,263043927,396597056,39120928,983967892,859688988,573348610,757045125,380805769,35195477,377632949,829882732,846684919,424336473,295503913,399731193,333004065,404203129,470281533,216161532,180372248,63721621,603524919,448698936,547035629,508884189,766872554,827762142,539832913,418468113,736999347,125809763,390377168,606274476,274986345,387888086,992868549,589147267,562330336,363813038,204580805,582651835,664945089,891751083,587281725,11393147,510833200,860228068,115405595,840582496,477023046,534611683,576222990,370540695,386169623,587841115,945406355,958558340,691187773,792269492,365030977,547762041,694957317,269294877,455912048,643046469,609832625,314407367,573570990,151381434,946720523,744605730,394448931,724141327,791980925,608858723,734400048,919365490,269074959,99950451,983222539,842854317,859747016,846312892,547168185,257440254,235029698,720658154,954410128,510678704,688237164,425998804,375191723,527981096,869759575,572736184,952769822,200571038,554931343,333076163,195715562,664820669,901269902,510102302,295954051,941335383,464428707,282442646,922183841,733484437,52295392,890470500,260624814]
  let n = scan()
  echo n.calc(n div 10000 * 10000,cached[n div 10000])
0