結果
問題 | No.148 試験監督(3) |
ユーザー | なお |
提出日時 | 2015-02-10 04:11:25 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 716 ms / 1,000 ms |
コード長 | 4,608 bytes |
コンパイル時間 | 1,285 ms |
コンパイル使用メモリ | 159,732 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-23 16:56:49 |
合計ジャッジ時間 | 6,363 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 149 ms
6,812 KB |
testcase_01 | AC | 260 ms
6,940 KB |
testcase_02 | AC | 589 ms
6,944 KB |
testcase_03 | AC | 536 ms
6,944 KB |
testcase_04 | AC | 716 ms
6,940 KB |
testcase_05 | AC | 513 ms
6,940 KB |
testcase_06 | AC | 403 ms
6,940 KB |
testcase_07 | AC | 626 ms
6,944 KB |
testcase_08 | AC | 616 ms
6,944 KB |
testcase_09 | AC | 3 ms
6,944 KB |
testcase_10 | AC | 2 ms
6,944 KB |
testcase_11 | AC | 1 ms
6,940 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long l; #define REP(i,n) for(int i=0;i<n;++i) int M=1e9+7,N,k[]={1,119948046,974067448,304661605,682498929,140928835,598816162,892704918,491101308,913230882,586350670,526658674,76479948,878381584,463847391,468116664,723816384,222176885,172827403,619965361,67347853,726686688,407719831,3669475,27368307,498440078,606322308,607649469,625544428,603835511,1669644,550969600,199888908,775147177,534491822,624903360,888050723,857549983,884343068,270603374,927880474,374934947,112249297,977168136,281863274,261319829,770511792,102309489,661224977,835330203,935080803,672118586,623534362,85322142,797848181,422713438,970055531,748359168,232253360,956163585,261384175,762863177,659224434,24300293,195888993,137550654,509096183,496537397,66404266,364911332,785113347,135500451,547665832,113905458,996122673,670821828,109838563,752194712,34538816,312536013,933245637,595959409,911398531,325284740,724691727,170238260,114985663,471822076,368925948,51595198,464456846,344053349,268838846,722807834,938269070,758827428,136026497,185163716,564758715,639320111,112390913,1840485,167240465,605298160,135498044,115579849,889410460,181445064,217544623,693326853,996097969,761545908,419363534,207103817,607730875,39280804,500780548,368878414,651081062,628370214,668123525,397417003,563432246,503167666,128487469,464643614,318951960,59719938,30977140,354990705,93940075,977544813,522049725,851663162,559947225,915199651,309058615,790715390,624577416,660966455,386027524,894659709,716986954,398145141,189239124,697868489,179518046,868431947,148528617,848419420,529726489,488043087,940567523,337883503,473718967,524012393,917084264,514251437,105419548,900904073,429277690,52757021,937409008,668564391,996164327,394996809,418537348,15393104,358655417,446827670,775305697,952124856,568392357,711263223,392838702,835720092,780072518,982142330,596737944,112916884,462639908,301178006,843321396,836420358,275105629,928715741,432030917,601095260,909210595,571901643,321685608,172844240,99199382,795864732,5003231,907257761,703397904,138744932,863250534,894162271,733333339,100166031,180898306,804272708,97830135,493898122,864869025,316571311,608823837,85051770,46819124,652279266,256141983,665181047,491415383,204194403,141827977,895259210,688809790,246808791,696628828,684205655,457469634,657283032,637939935,404533909,502297454,77511478,811575797,32074225,48053248,631265590,848924691,894517500,26011548,672903454,131772368,187129040,271198437,255041381,724464507,133269512,510650790,613729514,272814771,972590066,564188856,264639326,326159309,860780776,44135644,586418403,456152084,778806615,816929577,697422579,903466878,611223434,218107212,825527586,92255682,330425149,196345098,98875930,769795511,563593105,407518072,459822212,373745190,216838327,147050765,531982651,606241871,295898944,666493603,430345388,825871994,922419422,561011609,153796383,957939114,639423687,765215899,712565751,435887178,131119231,201339230,661083628,852304035,302579083,469928208,636059822,663307737,438269075,414236650,691030367,375297772,685756954,211487466,311095371,217598709,759994826,676526196,523449284,624148346,182270197,439411911,181058575,671734977,923976569,644050694,636309857,624500515,671075979,715264908,847440256,748510389,135656153,819801784,961808256,203191898,828454217,340030191,444094748,423951674,807827182,331910086,962158915,629786193,468747428,341080135,604177687,672850561,388537544,684748812,85157309,814362881,315587760,60625018,466459786,823845496,717927112,175638827,782723657,116667533,710965692,163928347,107234102,256473217,8947163,393556719,553063981,627655552,354655649,687265514,226478218,245795606,650859047,36292292,873791394,586445753,116698549,953634340,20450004,172114298,990631624,260466949,642772349,193781724,662565976,756154604,938420738,778983779,254189314,49031023,131731042,83868974,659873007,954913,549660657,315103615,426786760,346966053,253486451,965785236,65591903,321900901,860842034,492741665,160150497,532702135,867195255,377329025,20211256,847645126,494290402,847549272,788599446,3258987,128900492,698611116}; int f(int n){int b=25e5;l r=k[n/b];int m=n/b*b;while(m<n)m++,r=r*m%M;return r;} l e(l a,l b,l &m,l &n){l g=a;m=1;n=0;if(b)g=e(b,a%b,n,m),n-=(a/b)*m;return g;} int solve(){string c,p;cin>>c>>p;int q=p.size();l P=0,C=0,D=0,E,a,b;REP(i,q)P=P*10+p[i]-'0';if(q>10||P>=M)return 0;int d=c.size();REP(i,d)(C=C*10+c[i]-'0')%=M,D=D*10+c[i]-'0';if(d>11)D=1e11;if(D-2*P+1<0)return 0;E=(C-P+1+M)%M;if(E<P)return 0;e(f(E-P),M,a,b);return(f(E)*a%M+M)%M;} int main(){cin.tie(0);ios_base::sync_with_stdio(0);cin>>N;REP(i,N)cout<<solve()<<endl;}