自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(65)
  • 资源 (2)
  • 收藏
  • 关注

原创 Maximum Subarray

public class Solution { public int maxSubArray(int[] nums) { int start=0; int end=nums.length-1; return FindMax(nums,start,end); } public int FindMax(int[] num

2015-06-03 13:29:28 366

原创 Search Insert Position

public class Solution { public static int searchInsert(int[] nums, int target) { if(nums.length==0||nums==null) { return 0; } if(target<nums[0])

2015-05-25 23:21:54 306

原创 Valid Parentheses

Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.The brackets must close in the correct order, "()" and "()[]{}" are all va

2015-05-23 02:08:36 298

原创 Two Sum

Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two numbers such that they add up to the target, whe

2015-05-17 14:35:29 307

原创 1092. To Buy or Not to Buy (20)

#include #include using namespace std;int main(){ char ch[1001]; char ch1[1001]; gets(ch); gets(ch1); int index[101]; for(int i=0;i<101;i++) { index[i]=0; }

2015-03-24 14:24:50 455

原创 PAT 未完成

#include #include #include #include #include using namespace std;#define MAX 201#define INF 0x7fffffffstruct Node{ string name; int happy;};int edge[MAX][MAX];int dist[MAX];int ha

2015-03-12 11:42:34 395

原创 1030. Travel Plan (30)

#include #include #include using namespace std;#define MAX 501#define INF 0x7fffffffint dist[MAX];int pre[MAX];int cos[MAX][MAX];int cost[MAX];int edge[MAX][MAX];int visited[MAX];int n,m,s

2015-03-12 00:31:41 372

原创 1071. Speech Patterns (25)

#include#include #include #include using namespace std;int main(){ string tmp; getline(cin,tmp); map m; string tm; int i=0; vectorv; while(i<tmp.length()) {

2015-03-11 13:26:25 317

原创 保存一下,还没写完

#include #include #include using namespace std;struct node{ long int fenzi; long int fenmu;};long int gcd(long int a,long int b){ if(b==0) return a; else { r

2015-03-10 22:37:03 348

原创 05-图1. List Components (25)

#include #include #include #include #define MAX 20using namespace std;vector G[MAX];int visited[MAX];int visit[MAX];void dfs(int i){ visited[i]=1; printf("%d ",i); sort(G[i].begi

2015-03-09 15:33:03 570

原创 6-06. 任务调度的合理性(25)

#include #include #include #include using namespace std;int visited[101];vector edge[101];bool nocycle=true;void dfs(int k){ visited[k]=1; for(int i=0;i<edge[k].size();i++) {

2015-03-07 23:31:55 739

原创 1041. Be Unique (20)

#include #include #include using namespace std;int main(){ int n; cin>>n; int index[10001]; memset(index,0,sizeof(int)); vectorv; while(n--) { int tmp;

2015-03-05 00:18:16 420

原创 1039. Course List for Student (25)

#include #include #include #include #include #include #include using namespace std;int main(){ int n,k; cin>>n>>k; vectorv; multimapm; while(k--) { int a,b;

2015-03-04 23:25:44 271

原创 1025. PAT Ranking (25)

#include #include #include #include #include using namespace std;struct pat{ string id; int final_rank; int loc_number; int loc_rank; int grade;};int cmp(pat a,pat b){

2015-03-04 21:52:19 275

原创 数组-03. 冒泡法排序(20)

#include using namespace std;int main(){ int n,m; cin>>n>>m; int a[101]; for(int i=0;i<n;i++) { cin>>a[i]; } int tmp; for(int i=0;i<m;i++) { for(

2015-02-27 23:51:31 365

原创 数组-07. 求一批整数中出现最多的个位数字(20)

#include #include #include #include #include #include using namespace std;int main(){ int n; cin>>n; char ch[1001]; int index[10]; for(int i=0;i<10;i++) { index

2015-02-27 22:49:16 656

原创 结构-01. 有理数比较(10)

#include#includeusing namespace std;struct Node{ int fenzi; int fenmu;};int gcd(int a,int b){ if(b==0) return a; else return gcd(b,a%b);}int main(){ N

2015-02-27 21:36:09 771

原创 结构-02. 有理数加法(15)

#include#includeusing namespace std;struct Node{ int fenzi; int fenmu;};int gcd(int a,int b){ if(b==0) return a; else return gcd(b,a%b);}int main(){ N

2015-02-27 21:28:06 987

原创 数组-06. 找出不是两个数组共有的元素(20)

给定两个整型数组,本题要求找出不是两者共有的元素。输入格式:输入分别在2行中给出2个整型数组,每行先给出正整数N(输出格式:在一行中按照数字给出的顺序输出不是两数组共有的元素,数字间以空格分隔,但行末不得有多余的空格。题目保证至少存在一个这样的数字。同一数字不重复输出。输入样例:10 3 -5 2 8 0 3 5 -15 9 10011 6 4 8 2 6

2015-02-24 21:12:28 4320

原创 1081. Rational Sum (20)

#include #include long long int Gcd(long long int a,long long int b){ if(a%b==0) return b; else return Gcd(b,a%b);}long long int Lcm(long long int a,long long int b){ long l

2014-09-18 00:10:45 431

原创 hdoj Bone Collector dp问题

#include #include #include using namespace std;int c[1005];int w[1005];int dp[1005];int main(){ int t; cin>>t; while(t--) {int n,v; cin>>n>>v;

2014-09-17 02:56:40 339

转载 hdoj 1204 I NEED A OFFER!

#include #include #include #include double MAX(double a, double b){ return a>b?a:b;}using namespace std;int c[1001];double w[1001];// f[j]代表录取的概率。// 录取的概率:两所学校录取率为x,y,则录取率为1-(1-x)(1-y)

2014-09-17 02:34:50 375

原创 hdoj 1087 Super Jumping! Jumping! Jumping!

#include #include #include using namespace std;int main(){ int n; while(cin>>n&&n) { int i; int num[1001]; for(i=0;i<n;i++) { cin>>num[i+1]

2014-09-17 01:13:41 305

原创 HDOJ 2048 数塔

//// main.cpp// 11//// Created by hcw on 14-9-17.// Copyright (c) 2014年 hcw. All rights reserved.//#include #include using namespace std;int dp[110][110];int main(){ int n; cin

2014-09-17 00:39:45 383

原创 hdoj 1159 Common Subsequence LCS最大公共子序列问题

#include#include#include using namespace std;char s1[201],s2[201];int len[201][201]={0};int row,col;int LCS(const char* s1,const char *s2){ int i,j; int max; for(i=0;i<row;i++)

2014-09-16 19:42:39 358

转载 HDOJ 1501 Zipper 记忆化搜索

#include using namespace std;bool dp[201][201];char fir[201],sec[201],thi[402];int n,firLen,secLen,thiLen;bool isok;void dfs(int i,int j,int k){ if(k==thiLen) { isok=true;

2014-09-16 15:54:59 472

转载 Leetcode: Palindrome Partitioning

Given a string s, partition s such that every substring of the partition is a palindrome.Return all possible palindrome partitioning of s.For example, given s = "aab",Return [ ["aa","b"],

2014-09-15 02:27:23 322

原创 1071. Speech Patterns (25)

#include #include #include #include #include using namespace std;int main(){ string tmp; stack st; while(cin>>tmp) { string s; for(int i=0;i<tmp.size();i++)

2014-09-05 15:20:17 293

原创 1069. The Black Hole of Numbers (20)

#include #include#include #include #include using namespace std;bool cmp1(char a,char b){ return a>b;}bool cmp2(char a,char b){ return a<b;} int a,b; stringstream ss,ss1,ss2; void s

2014-09-05 14:15:22 300

转载 HDOJ 3791

#include #include using namespace std;bool issame(string a,string b){ if(a==b) return true; if(a[0]!=b[0]) return false; string a1,a2,b1,b2; for(int i=1;i<a.size();i++) { if(a[i]>a[0])

2014-09-04 00:51:09 304

原创 1053. Path of Equal Weight (30)

#include #include #include #include #include using namespace std;vectorv[105];int value[101];int n,s,m;int fa[105];//记录前面一个nodebool cmp(int x,int y){ return value[x]>value[y];}void prin

2014-09-03 21:36:20 285

转载 POJ 1157 LITTLE SHOP OF FLOWERS

因为要保持花束顺序,即求矩阵(m*

2014-09-02 00:27:56 361

原创 1019. General Palindromic Number (20)

#include #include #include #include using namespace std;vector result;void change(long int a,long int b){ int tmp; while(a){ tmp=a%b; result.push_back(tmp); a/=b; }}bool isPalindromi

2014-08-30 16:13:01 256

原创 1006. Sign In and Sign Out (25)

#include #include #include #include #include #include using namespace std;struct  Node {    string id;    int in;    int out;};bool cmp1(Node a,Node b){    return a.in

2014-08-25 02:13:19 312

原创 1074. Reversing Linked List (25)

#include #include #include #include using namespace std;struct Node{ int addr; int key; int next;};int main(){ int head,n,k; cin>>head>>n>>k; Node temp; vector v; for(int i=0;i<n;i++)

2014-08-24 16:45:08 273

原创 1046. Shortest Distance (20)

#include #include #include #include #include using namespace std;int main(){ int n; cin>>n; int arr[100001]; int count[100002]; int j=1; count[0]=0; for(int i=0;i<n;i++) { cin>>arr[i

2014-08-18 02:25:03 275

原创 1037. Magic Coupon (25)

#include #include #include using namespace std;bool cmp(int a,int b){ return a>b;}int main(){ int nc,np; cin>>nc; int tmp; vectora; vectorb; for(int i=0;i<nc;i++)

2014-08-13 02:20:13 354

原创 1036. Boys vs Girls (25)

#include #include #include #include using namespace std;struct Stu{ string name; char sex; string id; int grade; };bool cmp1(Stu a,Stu b){ return a.grade>b.grade;}bo

2014-08-13 01:56:39 254

原创 1030. Travel Plan (30)

#include #include #include #include using namespace std;#define MAX 500#define INTMAX 0x7fffffffstruct node{ int a[MAX][MAX]; int n;//顶点数 int e;//边数 int cost[MAX][MAX];};node

2014-08-12 21:37:53 264

原创 循环-02. 计算圆周率(15)

#include using namespace std;int main(){ double tmp,pai,fenzi,fenmu; pai=1; fenzi=1,fenmu=1; int i=1; cin>>tmp; while(fenzi/fenmu>=tmp) { fenzi*=i; fenmu

2014-08-11 23:27:04 384

计算机体系结构量化研究方法第五版答案(包括附录)

计算机体系结构量化研究方法第五版答案(包括附录),很全面的资料。

2015-05-24

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除