当前位置:网站首页>Solutions: word coverage restoration, longest serial number, Xiaoyu buys stationery, Xiaoyu's electricity bill
Solutions: word coverage restoration, longest serial number, Xiaoyu buys stationery, Xiaoyu's electricity bill
2022-07-06 04:12:00 【Pandaoxi】
List of articles
Word overlay restore
Title Description
A length of l ( 3 ≤ l ≤ 255 ) l(3\le l\le255) l(3≤l≤255) Is repeatedly pasted with boy and girl Two words , The post pasted words may cover the pasted words ( What is not covered is represented by a period ), Eventually, at least one character per word is not covered . How many are there boy How many? girl?
Input format
A line is repeatedly pasted with boy and girl Two word string .
Output format
Two lines , Two integers . First act boy The number of , Second behavior girl The number of .
Examples #1
The sample input #1
......boyogirlyy......girl.......
Sample output #1
4
2
Answer key
// Author:PanDaoxi
#include <iostream>
using namespace std;
int main(){
// Count
int boy=0,girl=0;
string a;
cin>>a;
int len=a.size();
for(int i=0;i<len-2;i++){
boy+=(a[i]=='b'||a[i+1]=='o'||a[i+2]=='y'?1:0);
if(i<len-3) girl+=(a[i]=='g'||a[i+1]=='i'||a[i+2]=='r'||a[i+3]=='l'?1:0);
}
cout<<boy<<endl<<girl;
return 0;
}

Longest hyphen
Title Description
The input length is n n n A sequence of positive integers , The length of the longest serial number in the output sequence is required .
A hyphen means in a sequence , Continuous natural number from small to large .
Input format
first line , An integer n n n.
The second line , n n n It's an integer a i a_i ai, Space between .
Output format
a number , The number of longest hyphens .
Examples #1
The sample input #1
10
1 5 6 2 3 4 5 6 8 9
Sample output #1
5
Tips
Data scale and agreement
about 100 % 100\% 100% The data of , Guarantee 1 ≤ n ≤ 1 0 4 1 \leq n \leq 10^4 1≤n≤104, 1 ≤ a i ≤ 1 0 9 1 \leq a_i \leq 10^9 1≤ai≤109.
Answer key

// Author:PanDaoxi
#include <iostream>
using namespace std;
int main(){
int n,a,b=1,c=0,d;
cin>>n>>a;
for(int i=1;i<n;i++){
cin>>d;
if(a<d&&d-a==1) b++;
else b=1; // A number is also a hyphen
if(b>c) c=b;
a=d;
}
cout<<c;
return 0;
}
Xiaoyu buys stationery
Title Description
The head teacher gave Xiaoyu a task , Go to the stationery store and buy as many signing pens as possible . It is known that the price of a signing pen is 1 1 1 element 9 9 9 horn , And the money given to Xiaoyu by the head teacher is a a a element b b b horn , Xiaoyu wants to know , How many signing pens can she buy at most .
Input format
Enter only one line of two integers , respectively a a a and b b b.
Output format
Output a line of integers , It means how many signing pens Xiaoyu can buy at most .
Examples #1
The sample input #1
10 3
Sample output #1
5
Tips
Data scale and agreement
For all test points , Guarantee 0 ≤ a ≤ 1 0 4 0 \leq a \leq 10^4 0≤a≤104, 0 ≤ b ≤ 9 0 \leq b \leq 9 0≤b≤9.
Answer key
Nothing to say , It's relatively simple .
// Author:PanDaoxi
#include <iostream>
using namespace std;
int main(){
int a,b;
cin>>a>>b;
cout<<(10*a+b)/19;
return 0;
}
The electricity charge of Xiaoyu family
Title Description
Summer is coming , The electricity consumption of each household has increased a lot , The corresponding electricity bill also paid more . Xiaoyu's family received a notice of electricity charge today . Xiaoyu saw that it said : According to the price of electricity in Fujian [2006]27 Regulation No , The monthly electricity consumption is 150 Kilowatt hours and below per kilowatt hour 0.4463 Yuan Executive , The monthly electricity consumption is 151~400 The part of kWh is per kWh 0.4663 Yuan Executive , The monthly electricity consumption is 401 Kilowatt hours and above per kilowatt hour 0.5663 Yuan Executive ; Xiaoyu wants to verify , Is the number of electricity bills due on the electricity bill correct . Please write a program , Total known electricity consumption , According to the tariff , Figure out how much electricity should be paid .
Input format
Enter an integer , Indicates the total electricity consumption ( In kilowatt hours ), No more than 10000.
Output format
Output a number , Keep it after the decimal point 1 position ( The unit is in yuan , Keep it after the decimal point 1 position ).
Examples #1
The sample input #1
267
Sample output #1
121.5
Answer key
Split billing , Write well if That's all right. .
#include <iostream>
#include <iomanip>
using namespace std;
int main(){
double s;
int n;
cin>>n;
if(n>400) s=150*0.4463+250*0.4663+(n-400)*0.5663;
else if(n>150) s=150*0.4463+(n-150)*0.4663;
else s=n*0.4463;
cout<<fixed<<setprecision(1)<<s;
return 0;
}

边栏推荐
- MySQL learning record 13 database connection pool, pooling technology, DBCP, c3p0
- Unity中几个重要类
- [disassembly] a visual air fryer. By the way, analyze the internal circuit
- Chinese brand hybrid technology: there is no best technical route, only better products
- 自动化测试的好处
- Ks003 mall system based on JSP and Servlet
- 2/13 qaq~~ greed + binary prefix sum + number theory (find the greatest common factor of multiple numbers)
- Global and Chinese markets for otolaryngology devices 2022-2028: Research Report on technology, participants, trends, market size and share
- Use js to complete an LRU cache
- 食品行业仓储条码管理系统解决方案
猜你喜欢

About some basic DP -- those things about coins (the basic introduction of DP)

关于进程、线程、协程、同步、异步、阻塞、非阻塞、并发、并行、串行的理解

Le compte racine de la base de données MySQL ne peut pas se connecter à distance à la solution

Recommendation system (IX) PNN model (product based neural networks)

【按鍵消抖】基於FPGA的按鍵消抖模塊開發

The Research Report "2022 RPA supplier strength matrix analysis of China's banking industry" was officially launched

题解:《单词覆盖还原》、《最长连号》、《小玉买文具》、《小玉家的电费》

Custom event of C (31)
![[PSO] Based on PSO particle swarm optimization, matlab simulation of the calculation of the lowest transportation cost of goods at material points, including transportation costs, agent conversion cos](/img/41/27ce3741ef29e87c0f3b954fdef87a.png)
[PSO] Based on PSO particle swarm optimization, matlab simulation of the calculation of the lowest transportation cost of goods at material points, including transportation costs, agent conversion cos

Web components series (VII) -- life cycle of custom components
随机推荐
Hashcode and equals
asp. Core is compatible with both JWT authentication and cookies authentication
2/13 qaq~~ greed + binary prefix sum + number theory (find the greatest common factor of multiple numbers)
【FPGA教程案例12】基于vivado核的复数乘法器设计与实现
729. 我的日程安排表 I(set or 动态开点线段树)
C form application of C (27)
Understanding of processes, threads, coroutines, synchronization, asynchrony, blocking, non blocking, concurrency, parallelism, and serialization
How to execute an SQL statement in MySQL
【PSO】基于PSO粒子群优化的物料点货物运输成本最低值计算matlab仿真,包括运输费用、代理人转换费用、运输方式转化费用和时间惩罚费用
Redis (replicate dictionary server) cache
《2022年中国银行业RPA供应商实力矩阵分析》研究报告正式启动
Comprehensive ability evaluation system
[disassembly] a visual air fryer. By the way, analyze the internal circuit
How does technology have the ability to solve problems perfectly
MySQL master-slave replication
使用JS完成一个LRU缓存
MySQL learning record 13 database connection pool, pooling technology, DBCP, c3p0
Slow SQL fetching and analysis of MySQL database
P2022 有趣的数(二分&数位dp)
MLAPI系列 - 04 - 网络变量和网络序列化【网络同步】