当前位置:网站首页>洛谷刷题心得记录
洛谷刷题心得记录
2022-06-27 07:35:00 【#math.h】
1.转化思想:元变角 ; 结果最后处理100 10% 120
2.四舍五入:
/* +0.5的话,如果大于等于0.5就往前进一位,小于0.5就不往前进,然后强制转换到int会向下取整,正好四舍五入到整数,这是一种我认为最简单的四舍五入方法。 如果需要四舍五入到某一位,那么就*多少多少然后再除就好了 比如小数点后一位就*10/10.0 后两位*100/100.0 跟一个.0代表是浮点运算恩,这样就不会除完是int了 法二: cout<<**floor**(s*10+0.5)/10.0;//返回s四舍五入小数点后第二位的结果 
4. double s=0.0000;//请注意精度
sn要用double,不然精度不够……
请注意除法两边数据类型(不能使是int,不然等于div运算)
5.数学思想:等比数列
6.注意输入的距离可能为小数,所以它要定义成浮点数。
7. unsigned long long n,ans=0; //坑就坑在这儿。天数都那么大了,总路程还会小吗???
8.c语言有sprintf和sscanf,对应stringstream字符串流的读和写
<stdlib.h>中还有数值与字符串相互转换的iota和atoi函数,感兴趣的可以自己去了解。用c语言的sprintf比C++的字符串流效率高,但是我还是想用C++的字符串,为啥?因为C++字符串的可拓展性和灵活性比较高嘛hhhh
9. 头文件中
count(ivec.begin() , ivec.end() , searchValue)这个函数作用是统计在一定范围内某一值出现的次数
10.2只鱼的可爱度可能是一样的,所以要离散化
重点说一下离散化: 对于下面4个数, 10, 12, 9, 15 那么对应的 第几大的数为: 2,3,1,4;也就是把很大的数转化成很小的值(一一对应,学过离散数学的人应该知道这个),具体如下: 10,12,9,15 先对应输入的顺序下标:1,2,3,4; 把这2行放到结构体里;然后这个结构体数组按照第一行(10,12,9,15)从小到大排序,比较函数应该很好写,排序后结果如下: 9,10,12,15;对应下一行为3,1,2,4; 然后把9,10,12,15 换成 1,2,3,4,这个结构体再按照第2行从小到大再排一次就行了,得到:第一行2,3,1,4,第2行 1,2,3,4;这个2,3,1,4 就是离散化后的结果,注意对于本题可能出现重复数字,所以 在把9,10,12,15 换成 1,2,3,4时要注意一点,如果 是 10,10, 12,15 要换成1,1,2,3; 输入数据可能为0,所以输入值要加1
11.桶的思想: cin>>a[i];//读入 g[a[i]]=1;//在集合中赋值为1
12.//in[j]-‘a’:读入中对应的第几个字母的位置,比如’a’对应0,‘b’对应1,‘c’对应2(0开始);
//in[j]-‘a’+n:读入中对应字母加上转移位数得到的字母的对应位置。
//比如说’c’这个字母移动3位,就是第2个字母向右移动3个,就是第五个字母,即’f’
//取余26是防止移动位数超过26导致炸掉
//再加上’a’,将对应位置还原成字母,再打出来
11.递推(初始条件先搞好) 找规律 多想递归
12.环状 可以取模
13.第二个就是——也算提高了知识水平——C++里实数型如果0除以一个负数得-0 = =这操作真是爆炸!最后一个点就不善意地坑了一下,需要加一个特判
边栏推荐
- boundvalueops和opsforvalue区别
- R language calculates Spearman correlation coefficient in parallel to speed up the construction of co occurrence network
- Cookie encryption 6
- 攻防演习防御体系构建之第一篇之介绍和防守的四个阶段
- 碎煤机crusher
- Speech signal processing - concept (4): Fourier transform, short-time Fourier transform, wavelet transform
- Yarn create vite reports an error 'd:\program' which is neither an internal or external command nor a runnable program or batch file
- log4j:WARN No such property [zipPermission] in org. apache. log4j. RollingFileAppender.
- Websocket database listening
- Window right click management
猜你喜欢

IDEA连接数据库报错

js用switch语句根据1-7输出对应英文星期几

再见了,敏捷Scrum

Gérer 1000 serveurs par personne? Cet outil d'automatisation o & M doit être maîtrisé
![[Kevin's third play in a row] is rust really slower than C? Further analyze queen micro assessment](/img/ac/44e0ecd04fbea5efd39d2cc75dea59.jpg)
[Kevin's third play in a row] is rust really slower than C? Further analyze queen micro assessment

File and multipartfile overview

Cookie encryption 6

JS output shape

Remote connection raspberry pie in VNC Viewer Mode

JS uses the while cycle to calculate how many years it will take to grow from 1000 yuan to 5000 yuan if the interest rate for many years of investment is 5%
随机推荐
How can the flower e-commerce 2.0 era go after the breakthrough from 0 to 1?
Coggle 30 Days of ML 7月竞赛学习
2022 cisp-pte (II) SQL injection
Nature、science、cell旗下刊物
js判断用户输入的数是否为质数(多种方法)
log4j:WARN No such property [zipPermission] in org.apache.log4j.RollingFileAppender.
Yarn create vite reports an error 'd:\program' which is neither an internal or external command nor a runnable program or batch file
大厂工作十年,年薪40万突然被裁员,公司想抛弃你,一分情面都不会留
[compilation principles] review outline of compilation principles of Shandong University
JS to print prime numbers between 1-100 and calculate the total number of optimized versions
File and multipartfile overview
Hutool symmetric encryption
Use uview to enable tabbar to display the corresponding number of tabbars according to permissions
manim 数学引擎
SQL考勤查询间隔一小时
Multi table associated query -- 07 -- hash join
Speech signal processing - concept (I): time spectrum (horizontal axis: time; vertical axis: amplitude), spectrum (horizontal axis: frequency; vertical axis: amplitude) -- Fourier transform -- > time
js中判断成绩是否合格,范围在0-100,否则重新输入
js输出1-100之间所有的质数并求总个数
剑指 Offer 07. 重建二叉树