当前位置:网站首页>Luogu daily three questions -- the next day
Luogu daily three questions -- the next day
2022-07-18 00:26:00 【Xiao Tang (๑ & gt; & lt; ๑)】
Catalog
P1957 Oral arithmetic exercises
P1308 [NOIP2011 Popularization group ] Count the number of words
P1125 [NOIP2008 Improvement group ] Silly little monkey
P1957 Oral arithmetic exercises
Title Description
Mr. Wang is teaching simple arithmetic . Careful Teacher Wang collected i Taoist students often do wrong oral arithmetic , And I want to compile it into an exercise . It's tedious to arrange these topics , For this reason, he wants to use computer programs to improve work efficiency . Mr. Wang hopes to reduce the workload of input as much as possible , such as \texttt{5+8}5+8 You'd better just input \texttt 55 and \texttt 88, The output results should be as detailed as possible to facilitate the use of later typesetting , For example, the above input is processed and then output \texttt{5+8=13}5+8=13 And the total length of the formula 66. Mr. Wang gives you this glorious task , Please program for him to realize the above functions .
Input format
First line value ii
And then ii Actions require input formulas , Each row may have three data or two data .
If the behavior has three data, the first data represents the operation type ,\texttt aa For addition operations ,\texttt bb For subtraction ,\texttt cc For multiplication , The next two data represent the number of operands participating in the operation .
If the behavior has two data , The operation type of this question is the same as that of the previous question , And these two data are operands .
Output format
Output 2\times i2×i That's ok . For each input expression , Output complete formula and result , The second line outputs the total length of the expression
I/o sample
Input #1 Copy
4 a 64 46 275 125 c 11 99 b 46 64
Output #1 Copy
64+46=110 9 275+125=400 11 11*99=1089 10 46-64=-18 9
explain / Tips
Data scale and agreement
about 50\%50% The data of , The input formula has three data , The first formula must have three data .
For all the data ,0<i\leq 500<i≤50, The operands are non negative integers and less than 1000010000.
# include <iostream>
using namespace std;
# include <string>
//char q[50];
string q;
string m;
//char m[50];
int main()
{
int n;
cin>>n;
string p,k,z;
int d,c;
for(int i=0;i<n;i++)
{
cin>>p;
if(p=="a")
{
cin>>q>>m;
int d=stoi(q);
//cout<<" Here we are " ;
int c=stoi(m);
int e=c+d;
string l=to_string(e);
// cout<<l;
cout<<d<<"+"<<c<<"="<<d+c<<endl;
cout<<q.length()+m.length()+2+l.length()<<endl;
z=p;
}
else if(p=="b")
{
cin>>q>>m;
int d=stoi(q);
int c=stoi(m);
string l=to_string(d-c);
cout<<d<<"-"<<c<<"="<<d-c<<endl;
cout<<q.length()+m.length()+2+l.length()<<endl;
z=p;
}
else if(p=="c")
{
cin>>q>>m;
int d=stoi(q);
int c=stoi(m);
// cout<<c*d;
string l=to_string(d*c);
// cout<<l;
cout<<d<<"*"<<c<<"="<<d*c<<endl;
cout<<q.length()+m.length()+2+l.length()<<endl;
z=p;
}
else
{
if(z=="a")
{
cin>>m;
int d=stoi(p);
int c=stoi(m);
string l=to_string(c+d);
cout<<d<<"+"<<c<<"="<<d+c<<endl;
cout<<p.length()+m.length()+2+l.length()<<endl;
// z=p;
}
else if(z=="b")
{
cin>>m;
int d=stoi(p);
int c=stoi(m);
string l=to_string(d-c);
cout<<d<<"-"<<c<<"="<<d-c<<endl;
cout<<p.length()+m.length()+2+l.length()<<endl;
// z=p;
}
else if(z=="c")
{
cin>>m;
int d=stoi(p);
int c=stoi(m);
string l=to_string(d*c);
cout<<d<<"*"<<c<<"="<<d*c<<endl;
cout<<p.length()+m.length()+2+l.length()<<endl;
// z=p;
}
}
// cin>>a[i];
}
// cin>>a;
// int len=strlen(a);
// cout<<len;
//
}P1308 [NOIP2011 Popularization group ] Count the number of words
Title Description
General text editors have the function of finding words , This function can quickly locate the position of specific words in the article , Some can also count the number of times a specific word appears in the article .
Now? , Please program to realize this function , The specific requirement is : Given a word , Please output the number of times it appears in a given article and the location of its first appearance . Be careful : When matching words , Case insensitive , But it requires a perfect match , That is to say, a given word must be exactly the same as an independent word in the article regardless of case ( See example 1), If a given word is only a part of a word in the article, it is not a match ( See example 2).
Input format
common 22 That's ok .
The first 11 Acts as a string , There are only letters in it , For a given word ;
The first 22 Acts as a string , It can only contain letters and spaces , Represents a given article .
Output format
a line , If a given word is found in the text, output two integers , Two integers are separated by a space , They are the number of times the words appear in the article and the first place they appear ( That is, when it first appears in the article , The position of the first letter of a word in the article , Location slave 00 Start ); If the word doesn't appear in the text , Then output an integer directly -1−1.
I/o sample
Input #1 Copy
To to be or not to be is a question
Output #1 Copy
2 0
Input #2 Copy
to Did the Ottoman Empire lose its power at that time
Output #2 Copy
-1
explain / Tips
Data range
1\leq1≤ The length of the first line of words \leq10≤10.
1\leq1≤ The length of the article \leq10^6≤106.
noip2011 Popularization Group No 2 topic
# include <bits/stdc++.h>
using namespace std;
int main()
{
string n;
//cin>>n;
getline(cin,n);
string m;
getline(cin,m);
//cin>>m;
// Lowercase all
//transform(n.begin(),n.end(),n.begin(),::tolower);
//
//
//transform(m.begin(),m.end(),m.begin(),::tolower);
//int l=n.length();
for (int i=0;i<n.length();++i){
n[i]=tolower(n[i]);
}
for (int i=0;i<m.length();++i){
m[i]=tolower(m[i]);
}
m=' '+m+' ';
n=' '+n+' ';
if(m.find(n)==string::npos)
{
cout<<-1;
}
else
{
int alp=m.find(n); // Record the position of the first occurrence
int blp=m.find(n),q=0; // Used to find the number of occurrences later
while(blp!=string::npos)
{
++q;
//cout<<q<<endl;
blp=m.find(n,blp+1);
}
cout<<q<<" "<<alp;
}
}P1125 [NOIP2008 Improvement group ] Silly little monkey
Title Description
Stupid little monkey has a small vocabulary , So every time I do multiple choice questions, I have a headache . But he found a way , It has been proved that , It's a very good way to choose the right option !
The specific description of this method is as follows : hypothesis \text{maxn}maxn It's the number of letters that appear most frequently in a word ,\text{minn}minn It's the number of letters that appear the least in a word , If \text{maxn}-\text{minn}maxn−minn It's a prime number , So stupid little monkey thinks it's a Lucky Word, Such a word is probably the right answer .
Input format
A word , Only lowercase letters are possible , And the length is less than 100100.
Output format
There are two lines , The first line is a string , Suppose the input word is Lucky Word, Then output Lucky Word, Otherwise output No Answer;
The second line is an integer , If the input word is Lucky Word, Output \text{maxn}-\text{minn}maxn−minn Value , Otherwise output 00.
I/o sample
Input #1 Copy
error
Output #1 Copy
Lucky Word 2
Input #2 Copy
olympic
Output #2 Copy
No Answer 0
explain / Tips
【 I/o sample 1 explain 】
word error The letters that appear most in \texttt rr There is 33 Time , The letter with the least number of occurrences appeared 11 Time ,3-1=23−1=2,22 Prime number .
【 I/o sample 2 explain 】
word olympic The letters that appear most in \texttt ii There is 11 Time , The letter with the least number of occurrences appeared 11 Time ,1-1=01−1=0,00 Not prime .
( The original problem has been corrected )
noip2008 Improve the first question
# include <bits/stdc++.h>
using namespace std;
char s[105];
int a[27];
int main()
{
cin>>s;
int l=strlen(s);
int c;
for(int i=0;i<l;i++)
{
c=s[i]-=97;
a[c]++;
}
sort(a,a+26);
//for(int i=0;i<26;i++)
//{
// cout<<a[i]<<"---"<<i<<" ";
//}
//cout<<a[25];
int max=a[25];
int min;
for(int i=0;i<26;i++)
{
if(a[i]!=0)
{
min=a[i];
break;
}
}
int y=max-min;
int r;
if(y==1||y==0)
{
cout<<"No Answer"<<endl<<"0";
}
else
{
for(r=2;r<y;r++)
{
if(y%r==0)
{
cout<<"No Answer"<<endl<<"0";
break;
}
}
if(r==y)
{
cout<<"Lucky Word"<<endl<<y;
}
}
return 0;
}边栏推荐
- 综合评价的基本理论
- Dedecms dream weaving system website link TXT format website map making tutorial
- Oracle P8架构师离职,怒喷MySQL是“糟糕的数据库”……
- 这段sql在pg执行会报错,Oracle没问题
- Process testing
- [unity learning 023] object pool Pro
- 2019CCPC秦皇岛HDU - 6736 F - Forest Program(dfs找环 组合数学)
- 从0开始的 TypeScriptの十四:内置工具类型
- NFT industry analysis of metauniverse: China's digital collection industry is expected to move towards standardization and differentiation
- 【数学建模暑期培训】CUMCM历年题分类 2000-2021年数模国赛赛题及求解模型
猜你喜欢

Things about caching in software design

【古月21讲】ROS入门系列(2)——发布者Publisher、订阅者Subscriber的编程实现+自定义话题消息编程实现

【数学建模暑期培训】Matlab之求代数方程的符号解和数值解

Alibaba cloud - object storage OSS cost optimization

Four thinking abilities that front-line technicians should pay attention to

Spark Tuning (VI): it's really good to be nice to everyone -- broadcast variables
![洛谷P3194 [HNOI2008]水平可见直线(计算几何+单调栈)](/img/a8/f2b2a6763bfc9e5f98010ccb57d63f.png)
洛谷P3194 [HNOI2008]水平可见直线(计算几何+单调栈)
![[mathematical modeling summer training] matlab drawing command](/img/a0/f4dd2496ac5bb702c822b23f360ab9.png)
[mathematical modeling summer training] matlab drawing command

NFT industry analysis of metauniverse: China's digital collection industry is expected to move towards standardization and differentiation

关于DP中完全背包的遍历次序探讨
随机推荐
接口测试——流程测试支持批量参数导入,测试效率直接拉满!
Electric razor touch chip-dlt8t10s-jericho
MFC|自绘CStatic刷新不及时问题
[Huawei online battle] download and run Huawei's official unity example code, prompting authentication failure and returning error code 100114
Smart breeding scheme based on Lora gateway
stack-protector enabled but compiler support broken
[mathematical modeling summer training] matlab drawing command
Filenotfounderror: the path does not exist when using pyinstaller to package mediapipe projects
这段sql在pg执行会报错,Oracle没问题
【答疑解惑】 裁员浪潮中,N+1 到底指什么?
Jupyter Notebook入门教程
Degree engine (XI): Audio loading
Difference between QPS and TPS
For 10 consecutive years, the "most commonly used" programming language for programmers ranked first is....
MFC实现类的序列化
【Jmeter】Win10 下载安装Jmeter 5.5
Letter combination of leecode17 phone number
Basic theory of comprehensive evaluation
拓扑排序原理
[mathematical modeling summer training] matlab for finding symbolic solutions and numerical solutions of algebraic equations