C.KbeautifulStringsCodeforcesRound#705(Div.2)题解xiaodangao

题目链接[C.KbeautifulStrings](http//codeforces.com/contest/1493/problem/C)

计算机科学

POJ.3585AccumulationDegree(树型DP)xiaodangao

题目链接[AccumulationDegree](http//poj.org/problem?id=3585)

计算机科学

Acwing.10有依赖的背包问题(树型DP,分组背包)xiaodangao

题目链接[Acwing.10有依赖的背包问题(树型DP,分组背包)](https//www.acwing.com/problem/content/description/10/)

计算机科学

Acwing.284金字塔(区间DP)题解xiaodangao

计算机科学

KPhDmath(数学)题解xiaodangao

K.PhDmath

timelimitpertest
8seconds
memorylimitpertest
1024megabytesinputstandardinputoutputstandardoutput

Johnnyisabrilliantmathematicsstudent.Helovesmathematicssincehewasachild,nowheisworkingonhisPhDthesis.Hefacesasmallmathematicalproblem,hehasandigitintegernumber(letuscallits),hewantstofindhowmanysubstringofsaredivisiblebyaprimenumberp.

Hissupervisorprofessorisonvacationnow,socanyouplayhisroleandhelphimwiththat?

Input

ThefirstlinecontainsthenumberoftestcasesT.EachofthenextTlinesrepresentsatestcase.Foreachtestcaseyouwillbegiven4numbers1 ≤ a, b ≤ 1018,1 ≤ n ≤ 106,2 ≤ p < 200.Wherea < b.sisnotdirectlygivenintheinput,youhavetocalculateitfromaandbasfollowssisthefirstndigitsfromthedecimalrepresentationofa / b(treata / bdecimalrepresentationasithasaninfinitedigitsandjusttakethefirstndigitsfromtheleft)

Output

Foreachtestcaseyoushouldprintonelinecontainingthenumberofsubstringsofsthatcanbedividedbypwithoutremainder.

ExamplesInputCopy3243524252415OutputCopy631Note

Forthefirsttestcaseinthesample,a=2,b=4,n=3andp=5.Sos=500andthereare6substringsthataredividedbypwhichare5,0,0,50,00,500.

计算机科学

poj.1179Polygon(区间DP)题解xiaodangao

题目链接[http//poj.org/problem?id=1179](poj)

计算机科学

Acwing199.余数之和(数学+思维)xiaodangao

计算机科学

AcWing198.反素数(数学+DFS)xiaodangao

计算机科学

Acwing.197.阶乘分解(题解)xiaodangao

计算机科学

JumpingMachine(集合选数问题)xiaodangao

JumpingMachine

计算机科学
145678