• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 众包
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
 






canexjtuzju

记录
 
 

Powered by 博客园
博客园 | 首页 | 新随笔 | 联系 | 订阅 订阅 | 管理

2014年6月26日

wikioi 1688--求逆序对
摘要: 题目描述:给定数组,求逆序对的个数思路:归并排序,归并的时候改变计数,当前面的元素比后面元素大则计数cnt+=(m-i)+1没有AC的版本 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #inclu... 阅读全文
posted @ 2014-06-26 22:47 canexjtuzju 阅读(145) 评论(0) 推荐(0)
 
wikioi 1497--求余运算
摘要: 题目描述:给定b,p,k要求(b^p)%k思路:主要是快速求幂运算,有递归和非递归两种思路。递归有错误,应该是溢出问题#include #include #include #include #include #include #include #include #include #include #... 阅读全文
posted @ 2014-06-26 22:12 canexjtuzju 阅读(179) 评论(0) 推荐(0)
 
面试金典--17.1
摘要: 题目描述:不用临时变量,直接交换两个数思路a = a+b;b = a- b;a = a-b 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #inclu... 阅读全文
posted @ 2014-06-26 20:53 canexjtuzju 阅读(98) 评论(0) 推荐(0)
 
面试金典--11.6
摘要: 题目描述:数组每行每列都是有序的,编写代码找到指定元素思路:(1)从数组右上角开始找,每次更新i,j(已经实现)(2)对每个元素,它必定是它右下角子二维数组的最小值,也必定是左上角子二维数组的最大值,这样可以减少规模,没有实现 1 #include 2 #include 3 #include ... 阅读全文
posted @ 2014-06-26 20:31 canexjtuzju 阅读(141) 评论(0) 推荐(0)
 
面试金典--11.5
摘要: 题目描述:给定排序后的字符串数组,中间有一些空串,要求找到给定字符串的位置思路:(1)遍历,最慢的(2)二分查找,当mid处为空串,就找到最近的非空串继续寻找。如果需要找空串?(单独处理) 1 #include 2 #include 3 #include 4 #include 5 ... 阅读全文
posted @ 2014-06-26 20:08 canexjtuzju 阅读(121) 评论(0) 推荐(0)
 
面试金典--11.2
摘要: 题目描述:给定一个字符串数组,将变位词排在相邻的位置思路:map即可这里发现一个问题,string用sort排序不能使引用,回头看看源码。 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #inclu... 阅读全文
posted @ 2014-06-26 13:52 canexjtuzju 阅读(158) 评论(0) 推荐(0)
 
面试金典--11.3
摘要: 题目描述:给定一个数组,数组是由一个排好序的数组循环旋转得到的,现在要在数组中找给定值思路:(1)递归,二分查找,左右子数组肯定会有一个是排好序的,比较a[mid]与a[l]的大小之后,判断哪部分排好序,然后判断目标值在哪部分特殊情况是:2 2 2 3 2 2 2 2这种情况,中间元素与左边元素相同... 阅读全文
posted @ 2014-06-26 12:59 canexjtuzju 阅读(176) 评论(0) 推荐(0)
 
面试金典--11.1
摘要: 题目描述:给定排序后数组A和B,其中A的末端有足够空间存B,编写算法,将B合并到A思路:题目的意思应该是不用额外空间,所以从两个数组的最后一个元素往前遍历,将大的放入A的末尾 1 #include 2 #include 3 #include 4 #include 5 #include 6 ... 阅读全文
posted @ 2014-06-26 11:16 canexjtuzju 阅读(102) 评论(0) 推荐(0)
 
编程之美--2.3
摘要: 题目描述:寻找发帖水王,转换一下就是:给定一个数组,找出出现次数大于n/2的元素思路:(1)排序,直接输出中间元素(2)O(N),每次删除两个不同元素,注意代码实现 1 #include 2 #include 3 #include 4 #include 5 #include 6 #incl... 阅读全文
posted @ 2014-06-26 10:46 canexjtuzju 阅读(249) 评论(0) 推荐(0)