记录题目中遇到的坑

来源:互联网 发布:苹果一体机软件下载 编辑:程序博客网 时间:2024/05/24 15:42

1.尽量用scanf和printf,不用cin和cout(太慢了),除非用

std::ios::sync_with_stdio(false)

取消同步
例题:http://poj.org/problem?id=1182(考察并查集,时间卡的很死)

2.高精度问题,看到问题中要输入1000个digits的数字表示高精度数字,如下描述:
Each input file contains one test case which gives a positive integer no more than 1000 digits.(警觉)
高精度资料模版:
https://www.cnblogs.com/ECJTUACM-873284962/p/6509429.html
例题:
https://www.patest.cn/contests/pat-a-practise/1136(模拟水题+高精度)
3.遇到输入digit的,转化为数字要小心,0000,-0000这类数字,
首先用char*去接受,然后在转化成数字。
最后输出的时候,要利用printf(“%04d”)打印数字显示digit,不要轻易改变循环中的数字,
要用临时变量去替代一下:
例题:
https://www.patest.cn/contests/pat-a-practise/1139(暴力+广搜)