----1.2.3蓝桥杯
文章平均质量分 52
XuRuiIsCoding
这个作者很懒,什么都没留下…
展开
-
改变世界的九种算法
密钥算法:对于网上银行的交易信息,其实一直有点纳闷,互联网上我把银行卡信息交给他。其他人应该也可以获取,从而得到我的信息。原来这种网站里是采用了密钥算法,所谓密钥算法。举个简单的例子,有三个人在一间屋子里,一个是pap,是你的朋友,一个是Nima,是你的敌人,还有一个是你。你需要做的是,在完全透明的情况下,将消息传给pap而Nima不能知道。我们假设传递的是一种颜色,这样会比较好理解。原创 2016-06-27 21:18:58 · 2885 阅读 · 0 评论 -
Leetcode - 75 - sortColors
题目 Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue.Here, we will use the int...原创 2017-11-09 17:28:43 · 235 阅读 · 0 评论 -
Leetcode - 80 -removeDuplicates
题目 Follow up for “Remove Duplicates”: What if duplicates are allowed at most twice?For example, Given sorted array nums = [1,1,1,2,2,3],Your function should return length = 5, with the first fiv原创 2017-11-09 16:51:06 · 427 阅读 · 0 评论 -
Leetcode - 283 - moveZeros
题目 Given an array nums, write a function to move all 0’s to the end of it while maintaining the relative order of the non-zero elements.For example, given nums = [0, 1, 0, 3, 12], after calling your原创 2017-11-09 10:51:17 · 464 阅读 · 0 评论 -
关于二分法的边界感悟-java实现
对于程序边界,你一定要维护住自己的标准,不能变。package ShiyiQi;/** * Created by xurui on 2017/11/7. */class binarySearch{ public int binarySearch(int arr[], int n, int target){ //[]为数学上的双闭区间的意思 i原创 2017-11-08 17:43:26 · 422 阅读 · 0 评论 -
算法day07
1.UVA 10327 Flip Sort Sorting in computer science is an important part. Almost every problem can be solved effeciently if sorted data are found. There are some excellent sorting algorithm which has a原创 2017-09-15 16:53:35 · 385 阅读 · 0 评论 -
算法day04
小结: A: memset(*指针,false,sizeof(指针))——快速的置0; B:深度优先搜索的基本模型void dfs(int step){ 判断边界 尝试每一种可能 for(i=1;i<=n;i++) { 继续下一步dfs(step +1); } 返回}Tips:遇到一个难题,解决后明天更新题目。原创 2017-09-12 22:50:56 · 394 阅读 · 0 评论 -
算法day03
1.POJ 1004 Financial Management printf("$%.2f",avg);主要注意最后这个输出格式,其他比较简单。2.POJ 1552 Double#include <stdio.h>#include <iostream>using namespace std;int main(){ int count,i,j,n,a[100]; scanf("%原创 2017-09-11 22:45:42 · 269 阅读 · 0 评论 -
算法day02
算法的第二天,复习一下搜索问题。 1.DFSvoid dfs(int step)//step表示站在第几个盒子前{ int i; if(step==n+1)//如果站在第n+1个盒子面前,则表示前n个盒子已经放好 { for(i=1;i<=n;i++) printf("%d ",a[i]); printf("\n")原创 2017-09-10 22:53:10 · 259 阅读 · 0 评论 -
算法day01
在继ACM之后,为了推免复试,再次翻开算法书,这次想有一些记录,方便日后查看。所以可能比较琐碎。 第一天复习了一下基本的排序问题: 1.冒泡排序for(i=1;i<=n-1;i++) for(j=i;j<=n-i;j++) if(a[j]>a[j+1]) { t=a[j];a[i]=a[j+1];a[j+1]=t;原创 2017-09-08 22:41:03 · 309 阅读 · 0 评论 -
算法day06
1. POJ 1488 TEX Quotes Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 9046 Accepted: 4743Description TEX is a typesetting language developed by Donald Knuth. It takes sour原创 2017-09-14 22:52:55 · 340 阅读 · 0 评论 -
算法day05
先决条件: A: fscanf函数原型为int fscanf(FILE*stream, constchar*format, [argument…]); 其功能为根据数据格式(format)从输入流(stream)中写入数据(argument);与fgets的差别在于:fscanf遇到空格和换行时结束,注意空格时也结束,fgets遇到空格不结束。例子: /*1.从标准输入中读取一个整数*/原创 2017-09-13 16:43:09 · 322 阅读 · 0 评论 -
动态规划:LCS
最长公共子序列时间限制:3000 ms | 内存限制:65535 KB难度:3描述咱们就不拐弯抹角了,如题,需要你做的就是写一个程序,得出最长公共子序列。tip:最长公共子序列也称作最长公共子串(不要求连续),英文缩写为LCS(Longest Common Subsequence)。其定义是,一个序列 S ,如果分别是两个或多个已知序列的子序列,且是所有符合原创 2016-05-04 18:08:03 · 484 阅读 · 0 评论 -
Leetcode - 349 - Intersection of Two Arrays - 类型转化,String<->int,object<->int
题目: Given two arrays, write a function to compute their intersection.Example: Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2].Note:Each element in the result must be unique.The result can b翻译 2017-11-16 16:22:15 · 239 阅读 · 0 评论