2019/02/12训练日记

一、训练心得
经历过无数次的PE后,我去看了别人的代码,输入输出也毫无差别,为什么我的是PE,才发现我的Set容器中混入了,空元素,虽然确实不太清楚代码段中哪一段会将为空的String放入set容器。所以注意
使用容器注意begin()是否为空串空字符。
使用容器注意begin()是否为空串空字符。
使用容器注意begin()是否为空串空字符。
字符串的操作就足够让人头疼,但是通过使用容器简化了算法。虽然因为不熟练需要码很久才能出来一道题。
自己很菜,还有48小时才刚刚做出来一道题。菜就多努力。

今天先分析一下明天要码的题干
Ugly numbers are numbers whose only prime factors are 2, 3 or 5. The sequence
1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, …
shows the first 11 ugly numbers. By convention, 1 is included.
Write a program to find and print the 1500’th ugly number.
Input
There is no input to this program.
Output
Output should consist of a single line as shown below, with ‘<number>’ replaced by the number
computed.
Sample Output
The 1500'th ugly number is <number>.

题面上是一个输出丑数,丑数的定义是只有2,3,5这三个素因数的数.
现在的思路是,先找到1500以内的所有素数,用筛法筛掉2,3,5素数的倍数
再从头输出直到1500,但既然是STL训练,应该不会这么简单,不是集合,不是栈,不是堆。(虽然目前没学会)先按这个思路走。

知识点回顾
memset()要用sizeof,基于内存拷贝,因为其函数参数为指针,指针的加减都是按字节计算。

posted @ 2019-02-12 23:28  风骨散人  阅读(75)  评论(0编辑  收藏  举报