Love丶FFC's Blog
字符串 APPAPT
中包含了两个单词 PAT
,其中第一个 PAT
是第 2 位(P
),第 4 位(A
),第 6 位(T
);第二个 PAT
是第 3 位(P
),第 4 位(A
),第 6 位(T
)。
现给定字符串,问一共可以形成多少个 PAT
?
输入只有一行,包含一个字符串,长度不超过105,只包含 P
、A
、T
三种字母。
在一行中输出给定字符串中包含多少个 PAT
。由于结果可能比较大,只输出对 1000000007 取余数的结果。
APPAPT
2
如果使用多层循环来进行判断,会导致超时,因此需要思考一个优化算法
1.例如PPPPAAAATTTT,对于每个A来说有4个P,对于每个T来说有16个PA,因此可以构成16*4个PAT
2.遍历字符串,每找到一个T就记录一次,每找到一个A就累加T,每找到一个P就累加AT
String = input() # 输入字符串 P = 0 PA = 0 PAT = 0 for i in range(0, len(String)): if String[i] == 'P': P += 1 elif String[i] == 'A': PA += P elif String[i] == 'T': PAT += PA print(PAT % 1000000007)
fruinly
b; Kalariya et al buy cialis online no prescription pdf casks cialis and viagra pack These results have not been published in a peer- reviewed scientific journal
engarma
Thus, the US FDA does not recommend withholding opioid replacement therapy in the context of other sedating medications; cautious medication management is advised buy priligy 60
cheap louis vuitton bags
I just wanted to thank you for the fast service. as well they look great. I received them a day earlier than expected. prefer the I will definitely continue to buy from this site. regardless I will recommend this site to my friends. Thanks!
cheap louis vuitton bags https://www.louisvuittonsoutletstore.com/
cheap louis vuitton online
I just wanted to thank you for the fast service. in addition they look great. I received them a day earlier than expected. particularly the I will definitely continue to buy from this site. blue jays I will recommend this site to my friends. Thanks!
cheap louis vuitton online https://www.bestlouisvuittonoutlet.com/
cheap jordans online
I just wanted to thank you for the fast service. and also they look great. I received them a day earlier than expected. just like the I will definitely continue to buy from this site. blue jays I will recommend this site to my friends. Thanks!
cheap jordans online https://www.realjordansretro.com/
cheap louis vuitton bags
I just wanted to thank you for the fast service. or possibly they look great. I received them a day earlier than expected. for example the I will definitely continue to buy from this site. in any event I will recommend this site to my friends. Thanks!
cheap louis vuitton bags https://www.cheapreallouisvuitton.com/
louis vuitton outlet
Read reviews and was a little hesitant since I had already inputted my order. and even but thank god, I had no issues. similar to the received item in a timely matter, they are in new condition. regardless so happy I made the purchase. Will be definitely be purchasing again.
louis vuitton outlet https://www.louisvuittonsoutletonline.com/
Preliaf
Management is complex in these cases, and in the authors experience, survival is more limited priligy reddit
Preliaf
These vibrations cause the three tiny bones in the middle ear to move, transmitting the sound to the inner ear levitra comprimes