随笔分类 -  算法

摘要:模板整理 二分(返回第一个等于x的元素的下标) int found(int a[],int left,int right,int x) { while (left < right) { int mid = (right + left) >> 1; if (a[mid] < x) left = mid 阅读全文
posted @ 2020-06-06 23:45 StreamAzure 阅读(263) 评论(0) 推荐(1) 编辑
摘要:一、文件的储存形式 分为文本(ASCII码)文件与二进制文件两类。 文本文件 文件每一个字节存放一个ASCII码,代表一个字符。如整数123在文本文件中占3个字节。 二进制文件 将数据以其在内存中的形式原样存放。如整数123和整数1234在二进制文件中均占4个字节。 二、文件操作 //文件指针变量 阅读全文
posted @ 2020-06-03 01:18 StreamAzure 阅读(443) 评论(0) 推荐(0) 编辑
摘要:1.【板子题】POJ 2387 Til the Cows Come Home 2.【最小生成树】POJ 2253 Frogger 3.【最大生成树】POJ 1797 Heavy Transportation 4.【反向建边】POJ 3268 Silver Cow Party 5.【判正环】Curre 阅读全文
posted @ 2020-05-21 00:48 StreamAzure 阅读(171) 评论(0) 推荐(0) 编辑
摘要:"A Alarm Clock" "B Ternary String" "C1 Simple Polygon Embedding" 阅读全文
posted @ 2020-05-18 01:30 StreamAzure 阅读(268) 评论(0) 推荐(0) 编辑
摘要:"B. Same Parity Summands" "D. Alice, Bob and Candies" "E. Special Elements" "G. Special Permutation" 阅读全文
posted @ 2020-05-17 22:50 StreamAzure 阅读(177) 评论(0) 推荐(0) 编辑
摘要:类的声明 class Stock//某人持有的股票 { private://私有成员,只能通过公用方法间接访问 std::string company;//股票所属公司 long shares;//持股数量 double share_value;//股票单价 double total_value;/ 阅读全文
posted @ 2020-04-29 22:55 StreamAzure 阅读(204) 评论(0) 推荐(0) 编辑
摘要:快速幂 原理 求ab。 例如,b=11时,其二进制为1011,又有11=23×1+22×0+21×1+20×1 所以 a11=a23+21+20 从而 \[ a^{11}=a^{2^3} \tim 阅读全文
posted @ 2020-04-29 18:07 StreamAzure 阅读(140) 评论(0) 推荐(0) 编辑
摘要:C题直接贪心,D题欧拉回路,理论上应该会做的…… 然后应该读题比较慢的关系,A题+B题各做了20分钟……还是15分钟内连切两道比较理想,毕竟挂了梯子,开CF的速度也不慢。 C. Circle of Monsters n只怪物站成一圈,第i只怪物有a[i]点生命值和b[i]点爆炸伤害。 阅读全文
posted @ 2020-04-11 02:59 StreamAzure 阅读(267) 评论(2) 推荐(0) 编辑
摘要:python输入输出格式 阅读全文
posted @ 2020-04-10 04:51 StreamAzure 阅读(541) 评论(0) 推荐(0) 编辑
摘要:紫书第六章 例题+习题 题解代码及总结 阅读全文
posted @ 2020-04-07 22:29 StreamAzure 阅读(194) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2020-04-03 23:22 StreamAzure 阅读(372) 评论(0) 推荐(0) 编辑
摘要:string.find() 用于搜索子串在母串中的位置,如果找到,返回子串首个元素的下标;如果找不到,返回s.npos map.count() map.count(Key),在map中检索索引Key,若其存在,返回true,否则返回false 注意仅能检索索引,不能检索值 C++ include i 阅读全文
posted @ 2020-03-31 18:09 StreamAzure 阅读(144) 评论(0) 推荐(0) 编辑
摘要:CF1324A Yet Another Tetris Problem 长度为n的数组a中有一组数,可以任意使其中一项+2,问能否使a中所有项的值相同。 感觉div.3的题目更多地在考简化问题的能力……比如原题目以俄罗斯方块作背景,让我想到的是能不能消除所有方块,导致代码很难写。但如果像上述一样简化题 阅读全文
posted @ 2020-03-29 00:03 StreamAzure 阅读(110) 评论(0) 推荐(0) 编辑
摘要:"CF1328A Divisibility Problem" 输入a,b,求a自增的次数,使得最终的a满足a%b==0 第一反应:for循环直到满足条件为止,然后果不其然TLE。说实话A题都是很弱智的,第一反应往往都会T,稍微思考一下就可以了…… 先判断a%b==0,再考虑详细情况:若$a 阅读全文
posted @ 2020-03-27 17:06 StreamAzure 阅读(161) 评论(0) 推荐(0) 编辑
摘要:用更高级的方法上分 阅读全文
posted @ 2020-03-27 04:26 StreamAzure 阅读(5653) 评论(8) 推荐(2) 编辑
摘要:紫书第五章 例题+习题 题解代码及总结 阅读全文
posted @ 2020-03-25 18:57 StreamAzure 阅读(148) 评论(0) 推荐(0) 编辑
摘要:紫书第四章 例题+习题 题解代码及总结 阅读全文
posted @ 2020-03-25 18:34 StreamAzure 阅读(247) 评论(0) 推荐(0) 编辑
摘要:紫书第三章 例题+习题 题解代码及总结 阅读全文
posted @ 2020-03-25 02:52 StreamAzure 阅读(127) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示