摘要: 本题是向量叉积的应用,应用向量叉积可以判断一个点是否在三角形内部。向量积 axb =|a|*|b|*sin当b在a的逆时针方向,向量积是正数,反之,是负数。由图可知三角形内部的点都在三角形边的同一侧。可以结合此性质解决本题。绿色和红色区域可以根据三角形行走的方向相消为0#include#includ... 阅读全文
posted @ 2015-12-04 22:46 varcom 阅读(288) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution { 2 public: 3 ListNode *getIntersectionNode(ListNode *headA, ListNode *headB) { 4 int la=0,lb=0; 5 ListNode* pt=... 阅读全文
posted @ 2015-06-14 22:37 varcom 阅读(116) 评论(0) 推荐(0) 编辑
摘要: 1 typedef struct Version 2 { 3 vector vec; 4 }Version; 5 int cmp(Version a,Version b) 6 { 7 int i; 8 int la=a.vec.size(),lb=b.vec.size();... 阅读全文
posted @ 2015-06-11 13:55 varcom 阅读(136) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution { 2 public: 3 int trailingZeroes(int n) { 4 int ans=0; 5 while(n) 6 { 7 ans+=n/5; 8 ... 阅读全文
posted @ 2015-06-11 10:57 varcom 阅读(107) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution { 2 public: 3 int titleToNumber(string s) { 4 int n=s.size(),i; 5 int ans=0; 6 for(i=0;i<n;i++) 7 ... 阅读全文
posted @ 2015-06-10 20:56 varcom 阅读(126) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution { 2 public: 3 int majorityElement(vector& nums) { 4 int n=nums.size(),i; 5 int m=nums[0]; 6 int cnt=1; 7... 阅读全文
posted @ 2015-06-10 20:23 varcom 阅读(144) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution { 2 public: 3 string convertToTitle(int n) { 4 string ans="",cur; 5 while(n) 6 { 7 n--; 8 ... 阅读全文
posted @ 2015-06-10 19:42 varcom 阅读(102) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution { 2 public: 3 void rotate(vector& nums, int k) { 4 int n=nums.size(); 5 k%=n; 6 if(k==0) 7 ... 阅读全文
posted @ 2015-06-10 15:32 varcom 阅读(145) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution { 2 public: 3 uint32_t reverseBits(uint32_t n) { 4 uint32_t ans=0; 5 int t=0; 6 while(n) 7 { 8 ... 阅读全文
posted @ 2015-06-10 13:58 varcom 阅读(124) 评论(0) 推荐(0) 编辑
摘要: 1 typedef unsigned int uint32_t; 2 class Solution { 3 public: 4 int hammingWeight(uint32_t n) { 5 int tot=0; 6 while(n) 7 ... 阅读全文
posted @ 2015-06-09 22:46 varcom 阅读(141) 评论(0) 推荐(0) 编辑