mfunction96 / hs2znoip Goto Github PK
View Code? Open in Web Editor NEWLicense: GNU General Public License v3.0
License: GNU General Public License v3.0
中文题面,很简单,签到题。
转换成绩为等级,不满足要求做特殊输出。
难点在多组输入,多组输入要用以下结构
int n;
while (scanf("%d", &n) == 1)
{
...
}
利用scanf
函数返回值判断输入终止条件。scanf
函数返回正确输入变量的个数,当输入无效时返回EOF
。
与之同理,cin
同样具有返回值可以作为输入终止的判断条件,常用以下结构:
int n;
while (cin >> n)
{
...
}
这样的话,题迎刃而解。
本题为阅读题,读懂后即可明白使用贪心法,比较简单。
贪心策略:
注意:
k
次操作,不能多不能少因此,只需要根据负数个数与操作数的关系,分情况计算即可Accepted。
中文题面,同样比较简单,属于签到题。
多组输入,与A题相同,多组输入不再重复讲解。
不过本题需要考虑清楚所有情况,最好的办法是设置缓存存储数据,再立一个flag
标记缓存中是否存在数据。
遍历字符串时,若flag
标记缓存中有数据且读取到了5
关键字,那么存储数据并清除缓存,否则继续读。
此外,注意最后的数据不要忘记存储,不然会WA。
Accepted代码
题意简单来说:
此题还有提示,针对输入
4 1 3 5
2 2 2 2
5 4 5 1
如果Emma选择第一行和第三行,Jack一定要选择
1
,因此选择第二行能达到Emma选择的最大值
根据提示思考片刻。
于是乎,题意变为了
选择每一行最小的,然后在最小的中选择最大
这样一来,题变得非常简单了。
这题没什么好讲的。。。。
英语阅读题,读懂了就会写,模拟题中的过程就可以Accepted。
注意: 用到了植树问题的起点终点的判断,注意不要多算。
读题便知本题为最短路模板题。
套最短路模板即可Accepted。
不过,由于朴素最短路算法,如朴素Dijkstra算法时间复杂度为O(n^2),时间复杂度较高并且存在优化空间。
根据Dijkstra算法过程,可以使用堆优化最小点权点的选择,因此采用优先队列(优先队列采用堆的数据结构)优化Dijkstra算法,时间复杂度期望从O(n^2)降低到O(nlogn)。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.