結果
問題 | No.148 試験監督(3) |
ユーザー | なお |
提出日時 | 2015-02-10 04:01:28 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 832 ms / 1,000 ms |
コード長 | 3,901 bytes |
コンパイル時間 | 1,262 ms |
コンパイル使用メモリ | 160,504 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-23 16:56:33 |
合計ジャッジ時間 | 7,643 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 255 ms
6,816 KB |
testcase_01 | AC | 364 ms
6,940 KB |
testcase_02 | AC | 705 ms
6,940 KB |
testcase_03 | AC | 599 ms
6,940 KB |
testcase_04 | AC | 832 ms
6,940 KB |
testcase_05 | AC | 744 ms
6,944 KB |
testcase_06 | AC | 494 ms
6,944 KB |
testcase_07 | AC | 733 ms
6,944 KB |
testcase_08 | AC | 605 ms
6,940 KB |
testcase_09 | AC | 11 ms
6,944 KB |
testcase_10 | AC | 12 ms
6,940 KB |
testcase_11 | AC | 1 ms
6,944 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,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 f(int n){int b=3e6;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>>N;REP(i,N)cout<<solve()<<endl;}