Love丶FFC's Blog
文本压缩有很多种方法,这里我们只考虑最简单的一种:把由相同字符组成的一个连续的片段用这个字符和片段中含有这个字符的个数来表示。例如 ccccc
就用 5c
来表示。如果字符没有重复,就原样输出。例如 aba
压缩后仍然是 aba
。
解压方法就是反过来,把形如 5c
这样的表示恢复为 ccccc
。
本题需要你根据压缩或解压的要求,对给定字符串进行处理。这里我们简单地假设原始字符串是完全由英文字母和空格组成的非空字符串。
输入第一行给出一个字符,如果是 C
就表示下面的字符串需要被压缩;如果是 D
就表示下面的字符串需要被解压。第二行给出需要被压缩或解压的不超过 1000 个字符的字符串,以回车结尾。题目保证字符重复个数在整型范围内,且输出文件不超过 1MB。
根据要求压缩或解压字符串,并在一行中输出结果。
C
TTTTThhiiiis isssss a tesssst CAaaa as
5T2h4is i5s a3 te4st CA3a as
D
5T2h4is i5s a3 te4st CA3a as10Z
TTTTThhiiiis isssss a tesssst CAaaa asZZZZZZZZZZ
1.无论压缩还是解压,都需要使用字符串拼接,对于判断的情况都是每一位与下一位进行
2.对于压缩,重点在于判断字符连续相同的情况并计数,同时对最后两个字符进行单独判断
3.对于解压,重点在于判断字符是数字还是字母(空格),同时需要使用while循环进行循环后移
Choose = input() String = input() NewString = "" if Choose == 'C': # 压缩 Count = 1 # 字符连续相同的个数 for i in range(len(String) - 1): # 判断前n-1个字符的情况,最后一个字符需要单独判断,否则会下标越界 if String[i] == String[i + 1]: # 下一位字符相同 Count += 1 else: # 下一位字符不同 if Count == 1: # 该位字符没有连续出现 NewString += String[i] else: # 改为字符连续出现过Count次 NewString += str(Count) + String[i] # 拼接字符串 Count = 1 # 重新统计 if String[len(String) - 2] != String[len(String) - 1]: # 最后两位字符不同 NewString += String[len(String) - 1] else: # 最后两位字符相同 NewString += str(Count) + String[len(String) - 1] elif Choose == 'D': # 解压 i = 0 Count = '' while i < len(String): # 遍历字符串 if String[i].isnumeric(): # 该字符是数字 Count += String[i] for j in range(i + 1, len(String)): # 遍历剩余字符串 if String[j].isnumeric(): # 下一字符仍是数字 Count += String[j] # 将该数字拼接,例如1235A,需要理解为1235个A else: # 下一字符不再是数字 NewString += int(Count) * String[j] # 将1235A进行1235*A运算 i = j + 1 # 循环右移,中间部分不再判断 break else: # 该字符是字母(空格),单独拼接 NewString += String[i] i += 1 Count = '' print(NewString)
Abupguele
It was claimed that Flo Jo was using performance enhancing drugs during her career, despite the fact that she had never tested positive lasix online no prescription
louis vuitton outlet online
I just wanted to thank you for the fast service. or a they look great. I received them a day earlier than expected. cherish the I will definitely continue to buy from this site. in any event I will recommend this site to my friends. Thanks!
louis vuitton outlet online https://www.bestlouisvuittonoutlet.com/
cheap louis vuitton bags
I just wanted to thank you for the fast service. as they look great. I received them a day earlier than expected. similar to I will definitely continue to buy from this site. in either case I will recommend this site to my friends. Thanks!
cheap louis vuitton bags https://www.louisvuittonsoutletstore.com/
Knitant
The people baroreceptor lower blood pressure behind the curtains hurried over buying generic cialis online safe
authentic cheap jordans
Read reviews and was a little hesitant since I had already inputted my order. or simply but thank god, I had no issues. for instance received item in a timely matter, they are in new condition. you decide so happy I made the purchase. Will be definitely be purchasing again.
authentic cheap jordans https://www.cheapretrojordan.com/
cheap jordans online
Read reviews and was a little hesitant since I had already inputted my order. or perhaps even but thank god, I had no issues. similar to the reduction received item in a timely matter, they are in new condition. no matter what so happy I made the purchase. Will be definitely be purchasing again.
cheap jordans online https://www.realcheapjordan.com/
cheap jordans
Read reviews and was a little hesitant since I had already inputted my order. to but thank god, I had no issues. choose the received item in a timely matter, they are in new condition. you decide so happy I made the purchase. Will be definitely be purchasing again.
cheap jordans https://www.realjordansshoes.com/
cheap louis vuitton bags
Read reviews and was a little hesitant since I had already inputted my order. potentially but thank god, I had no issues. as good as the received item in a timely matter, they are in new condition. you ultimately choose so happy I made the purchase. Will be definitely be purchasing again.
cheap louis vuitton bags https://www.louisvuittonsoutletonline.com/
authentic cheap jordans
Read reviews and was a little hesitant since I had already inputted my order. along with but thank god, I had no issues. simillar to the received item in a timely matter, they are in new condition. in any event so happy I made the purchase. Will be definitely be purchasing again.
authentic cheap jordans https://www.realjordansretro.com/
https://cse.google.so/url?q=https://www.topchristianlouboutinoutlet.com/
|Every woman should at least have a few key items in her closet. It is important to have jeans hemmed for sneakers and some for heels, then a couple pairs of darker, dressier slacks. Let’s not forget the mainstay for every woman, the little black dress.
https://images.google.com.gi/url?sa=t&url=https://www.topfakeyeezys.com/
{Casual up-dos are a good way to pick up the hair from your shoulders. Long, loose hair can get in the way during work or play. When you’re out of time, put your hair up in a bun!
invoimi
Results were expressed as mean and standard deviation of the mean propecia fast delivery
DarrylBox
tadalafil canadian pharmacy
AlanLit
feldene cream
Michaelsmopy
budesonide online
DarrylBox
buy erectafil 20
MaryLit
generic paxil mexico
Davidevelf
prednisolone medicine
DarrylBox
ampicillin price in south africa
Pipe fittings supplier
يتضح التزام إيليت بايب Elite Pipe بإرضاء العملاء في جداول التسليم الفوري وخدمة ما بعد البيع الاستثنائية.
JackLit
buy lyrica uk
Michaelsmopy
tretinoin 0.1 cream online
AlanLit
gabapentin 25mg tablets
DarrylBox
purchase vermox
Michaelsmopy
canadian pharmacy cafergot
elitepipeiraq.com
ElitePipe Plastic Factory – Your One-Stop Piping Solution in Iraq! 🌍 🏭 Elite Pipe Plastic Factory takes pride in being a trusted manufacturer and supplier of superior plastic piping solutions in Iraq. With our comprehensive product range and unwavering commitment to quality, we are your go-to source for all your piping needs. ✅ HDPE, UPVC, and LDPE Pipes: Our high-quality High-Density Polyethylene (HDPE), Unplasticized Polyvinyl Chloride (UPVC), and Low-Density Polyethylene (LDPE) pipes are engineered to provide exceptional durability, excellent flow characteristics, and resistance to corrosion. Whether it’s water supply, irrigation, or industrial applications, our pipes deliver unmatched performance. 🔩 Butt Welding Machines & Electrofusion Welding EF Machines: We offer state-of-the-art Butt Welding Machines and Electrofusion Welding EF Machines that ensure precise and efficient joining of pipes. These cutting-edge machines guarantee strong and leak-proof connections, meeting the highest industry standards. 🔌 Fittings & Electrofusion Fittings: Complementing our pipe offerings, we provide a wide range of fittings and electrofusion fittings. These products are designed to facilitate seamless installation, enabling reliable connections and optimal system performance. 🌾 Agriculture Pipes: Elite Pipe Plastic Factory understands the importance of efficient irrigation systems in agriculture. Our specially designed agriculture pipes deliver water efficiently to enhance crop growth and maximize yield. Count on us for durable and reliable solutions for your agricultural needs. 🤝 We are committed to delivering products that exceed your expectations. With our superior quality, advanced technology, and dedicated customer service, Elite Pipe Plastic Factory is the trusted partner you can rely on. 📞 Contact us today to discuss your project requirements and experience the excellence of Elite Pipe Plastic Factory! Let us be your preferred choice for top-notch plastic piping solutions in Iraq. 🚀
6 pvc pipe 20
This was beautiful Admin. Thank you for your reflections.
AlanLit
propecia cost
CurtisHed
10 mg baclofen canada
JoeLit
trazodone 12.5 mg
JosephKip
cheapest propecia online
Richardatone
tenormin 50mg
JosephKip
phenergan canada otc
CurtisHed
buy tamaxophen
DavisIgnip
levaquin buy online
Elwoodexcix
cheap cialis online canadian pharmacy
SamLit
where can i buy metformin over the counter
Davidevelf
metformin er 500mg
Williamjotly
lioresal cost
DavisIgnip
tretinoin pharmacy
SueLit
tretinoin online
JosephKip
triamterene for sale
CurtisHed
dexamethasone 2mg tablets price
Michaelsmopy
phenergan tablets
DarrylBox
tamoxifen buy australia
DavisIgnip
buy lipitor 10 mg
DarrylBox
cheap levaquin
DarrylBox
atarax canada
Williamjotly
phenergan 25mg for sale
Elwoodexcix
buy generic atarax
JackLit
cheap cymbalta prescription
MaryLit
zithromax order
Richardatone
prednisolone 5mg tablets for sale
Elwoodexcix
purchase levaquin
AshLit
lexapro online usa
Williamjotly
mail pharmacy
JackLit
retin-a generic
SueLit
triamterene hctz 37.5
SueLit
lipitor brand coupon
SueLit
metformin tablets where to buy
Richardatone
dexamethasone 10 mg
SamLit
robaxin 750 uk
ZakLit
tamoxifen 40 mg
DarrylBox
triamterene 37.5 mg tab
SueLit
atarax drug
SamLit
how much is robaxin 500mg
DarrylBox
overseas online pharmacy
Michaelsmopy
triamterene/hctz 37.5-25 mg
Michaelsmopy
triamterene/hctz 37.5-25 mg
SueLit
cymbalta 80 mg
SueLit
generic pharmacy online
IvyLit
atarax 10mg tablet price
Michaelsmopy
levaquin.com
Michaelsmopy
phenergan 25mg cost
SamLit
atarax for sleep
Elwoodexcix
atarax australia
JosephKip
tenormin price
Michaelsmopy
canadian discount pharmacy
AlanLit
tamoxifen gel
SamuelEcors
prazosin 5 mg cap
Richardatone
robaxin 500mg for dogs
AshLit
how to buy amoxicillin online
DavisIgnip
cialis men
DavisIgnip
prazosin 5 mg cap
Michaelsmopy
levaquin levofloxacin
Michaelsmopy
triamterene generic brand name
JosephKip
tamoxifen tablets for sale
SamLit
buy glucophage uk
AlanLit
atarax 10 mg tablet
MaryLit
buy prednisolone
EyeLit
retin a 0.8
Richardatone
prednisolone tablets uk
CurtisHed
baclofen 100mg
DarrylBox
buy levaquin online
DarrylBox
nolvadex 10 mg tablet price
SamuelEcors
atarax for eczema
JoeLit
average cost of generic lipitor
JoeLit
buy azithromycin canada
MaryLit
prednisolone pharmacy
ZakLit
prazosin pill
MaryLit
buy cymbalta in india
MaryLit
ebaylevaquin
Michaelsmopy
where can i get synthroid
SamuelEcors
diflucan 150 mg price
Michaelsmopy
synthroid 35
SamLit
diflucan 400mg without prescription
AlanLit
cephalexin 150 mg tablets
Elwoodexcix
azithromycin generic price
AlanLit
can you buy ventolin over the counter in uk
MaryLit
medicine bactrim
ZakLit
buy doxycycline online 270 tabs
SamLit
phenergan gel otc
AshLit
prinivil lisinopril
AshLit
synthroid tablet 125 mcg cost
Davidevelf
medicine voltaren 75 mg
MaryLit
voltaren 25mg price
Davidevelf
strattera buy online no prescription
Richardatone
tizanidine 3 mg
AlanLit
diclofenac pills uk
SamuelEcors
diflucan no prescription
Richardatone
bactrim online no prescrition
Michaelsmopy
buy azithromycin online without prescription
SamLit
keflex 500 tablet
SamLit
pharmacy delivery
Williamjotly
buy accutane 20mg online
SamuelEcors
diclofenac 1.5
AshLit
inderal buy online uk
CurtisHed
lyrica for sale uk
DavisIgnip
cephalexin 500mg tablets cost
JosephKip
zestril pill
DarrylBox
prednisone 20mg tab cost
JosephKip
accutane 20 mg for sale
SueLit
lisinopril 2.5 mg coupon
SueLit
synthroid 250 mcg
CurtisHed
hydroxychloroquine over the counter
JosephKip
how much is propecia
ZakLit
propecia without prescription usa
CurtisHed
plaquenil cost
Davidevelf
accutane prescription nz
SueLit
can you buy diflucan without a prescription
MaryLit
diflucan without get a prescription online
SueLit
prescription diclofenac gel
SueLit
hydroxychloroquine 50 mg
IvyLit
suhagra online india
IvyLit
zithromax 250 capsules
SamuelEcors
keflex 500mg online
ZakLit
suhagra
AshLit
lisinopril 10 mg over the counter
Davidevelf
prednisone price australia
DarrylBox
where to buy lyrica cheap
MaryLit
keflex price in india