- 博客(10)
- 收藏
- 关注
原创 将string转为stdin输入
通过lex生成的scanner需要通过stdin,或者文件读取来扫描文件,而z3能用to_smt2()输出string我们希望将z3生成的string转成stdin,供我们自己的编译器使用1.最简单的方法是使用freopen,打开一个文件,将string输入该文件中,然后再用freopen,将文件的内容作为stdin读出,该方法存在问题主要是效率较低,文件读写需要磁盘操作,会降低速度.2.一种可行的方案是将其读入一个管道中,然后再从管道中定向到stdin中,具体操作如下。 strin
2021-05-22 14:57:54
314
2
原创 修改堆栈默认大小
修改堆栈大小对于递归调用嵌套很深的情况,很容易出现堆栈溢出的情况在linux下可以使用下述命令查看堆栈大小ulimit -s在shell脚本中可以使用下述命令来修改堆栈大小ulimit -s 10240(KB)但是在linux下调试不如xcode下调试方便,因此可以在xcode中修改相应的堆栈大小设置在navigator中找到项目,然后搜索other linker flags 添加 -W1,-stack_size,10000000 注意:要打逗号...
2021-03-22 11:56:44
1317
原创 PAT1068
1068. Find More Coins (30)时间限制150 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueEva loves to collect coins from all over the universe, including some other planets like Mars. One day she visited a...
2018-04-18 09:49:57
260
原创 pat中关于并查集的题目&&以及类似dfs解法
点击打开链接:https://www.patest.cn/contests/pat-a-practise/1013并查集:主要是find和union函数:void unionn(int a,int b){ int x=find(a); int y=find(b); if(x!=y){ pre[x]=y; }}int find(int k){ ...
2018-03-17 12:05:57
195
原创 pat中有关于排队模拟的问题
1017. Queueing at Bank (25)时间限制400 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueSuppose a bank has K windows open for service. There is a yellow line in front of the windows which devides the wai...
2018-03-15 09:39:16
367
原创 与树相关的pat题目
1.1020:1020. Tree Traversals (25)时间限制400 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueSuppose that all the keys in a binary tree are distinct positive integers. Given the postorder and inorder tr...
2018-03-14 12:59:26
299
转载 树状数组
转自:https://www.cnblogs.com/hsd-/p/6139376.html树状数组彻底入门int lowbit(int t){return t&(-t);}void add(int x,int y){for(int i=x;i<=n;i+=lowbit(i))tree[i]+=y;}int getsum(int x){int ans=0;for(int i=x;i&...
2018-03-09 22:19:31
126
原创 pat1045
1045. Favorite Color Stripe (30)时间限制200 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueEva is trying to make her own color stripe out of a given one. She would like to keep only her favorite colors...
2018-03-06 20:13:39
160
原创 pat1043 数组实现
1043. Is It a Binary Search Tree (25)时间限制400 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueA Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties:The...
2018-03-05 15:39:20
144
原创 pat1038
这一问就是要将找出各个字符串如何组合才能使得组成的数字最小;首先我的思路是:关键在于如何寻找任何两个字符串的排列方式,写成一个cmp的bool类型函数,然后用sort,将其排序,然后将所有的字符串相连接成一个较长的字符串,最后输出来,注意去掉前面的0;在写cmp函数时,我的思路是:从前到后比较两个字符串的每一位,找到第一位不同的时候就返回这位数字的大小比较,如果直到一个字符串结束时都全部一样,...
2018-03-03 23:00:14
182
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人