当前位置:网站首页>洛谷刷题心得记录
洛谷刷题心得记录
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 = =这操作真是爆炸!最后一个点就不善意地坑了一下,需要加一个特判
边栏推荐
- (笔记)Anaconda-Navigator闪退解决方法
- 「短视频」临夏消防救援支队开展消防安全培训授课
- R language calculates Spearman correlation coefficient in parallel to speed up the construction of co occurrence network
- 安装jenkins
- 突破从0到1后,鲜花电商2.0时代怎么走?
- Guava tutorial collect some cases and write Google tool classes slowly
- JS print 99 multiplication table
- JDBC参数化查询示例
- JS to print prime numbers between 1-100 and calculate the total number of optimized versions
- Speech signal feature extraction process: input speech signal - framing, pre emphasis, windowing, fft- > STFT spectrum (including amplitude and phase) - square the complex number - > amplitude spectru
猜你喜欢

js求所有水仙花数

Cookie encryption 7 fidder analysis phase

JS to determine whether the result is qualified, the range is 0-100, otherwise re-enter

Gérer 1000 serveurs par personne? Cet outil d'automatisation o & M doit être maîtrisé

js成绩奖惩例题

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

One person manages 1000 servers? This automatic operation and maintenance tool must be mastered

2. QT components used in the project

JS use the switch statement to output the corresponding English day of the week according to 1-7

【编译原理】山东大学编译原理复习提纲
随机推荐
基础知识 | js基础
Speech synthesis: tacotron explains [end-to-end speech synthesis model] [compared with traditional speech synthesis, it does not have complex phonetics and acoustic feature modules, but only uses < te
碎煤机crusher
js中如何查看程序运行时间(计时器)
ACM课程学期总结
语音信号处理-概念(二):幅度谱(短时傅里叶变换谱/STFT spectrum)、梅尔谱(Mel spectrum)【语音的深度学习主要用幅度谱、梅尔谱】【用librosa或torchaudio提取】
Installation and functions of uview
Delay queue `delayqueue`
Origin of forward slash and backslash
R language consumption behavior statistics based on association rules and cluster analysis
js用switch输出成绩是否合格
Coggle 30 Days of ML 7月竞赛学习
How torch. gather works
2. QT components used in the project
Error in idea connection database
突破从0到1后,鲜花电商2.0时代怎么走?
游戏六边形地图的实现
volatile 和 synchronized 到底啥区别?
MySQL
什么是浮选机?