自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(32)
  • 资源 (1)
  • 收藏
  • 关注

原创 PAT 1055. The World's Richest (25)

//1055. The World's Richest (25)//这道题主要方法很简单,但是很容易超时,所以需要适当的剪枝。//剪枝的方法是: 另外对age开辟一个数组,由于每次只需要输出给定范围内的最多100个结果,所以对相同age的100个以后的数据不做考虑,建立age在整个数组中的索引。//acc#include #include #include using namespa

2015-03-16 08:37:32 343

原创 PAT 1053. Path of Equal Weight (30)

//1053. Path of Equal Weight (30)//简单的dfs//accept#include #include #include using namespace std;bool road[105][105] = {false};bool leaf[105] = {false};int n, m, s;int wei[105];int currwei

2015-03-16 08:36:29 357

原创 PAT 1054. The Dominant Color (20)

////1054 acc#include #include using namespace std;int t[1<<24+1] = {0};int main(){ int M, N; cin >> M >> N; int i; int x; int bzd; int len = 0; int index; for(i=0;i<M*N;i++) { sc

2015-03-16 08:36:23 312

原创 PAT 1052. Linked List Sorting (25)

//1052. Linked List Sorting (25)//第三个case测试:输出格式是否为05d,尤其是输出起始节点。//最后一个case是测试当链表node数量为0时,是否输出正确结果。这个时候不是直接return 0就可以。#include #include #include #include #include using namespace std;

2015-03-16 08:35:45 329

原创 PAT 1051. Pop Sequence (25)

//1051. Pop Sequence (25)//一定记得进行完之后要将所有的元素都pop出来才能得到正确结果。//acc#include #include using namespace std;int main(){ int M, N, K; cin >> M >> N >> K; if (M == 0) { cout << "NO"; return 0;

2015-03-16 08:34:48 647

原创 PAT 1050. String Subtraction (20)

//1050. String Subtraction (20)//acc#include #include using namespace std;int main(){ char a; char s1[10001], s2[10001]; int len1 = 0, len2 = 0; int flag = true; int i, j; while (scanf

2015-03-16 08:33:32 377

原创 PAT 1047. Student List for Course (25)

//1047. Student List for Course (25)//受不了cin和cout了,一用就超时了,。。。。。。。。。。//accept#include #include #include using namespace std;//typedef struct //{// int stu[40005];// int total;//}Course;

2015-03-16 08:30:54 408

原创 PAT 1045. Favorite Color Stripe (30)

////1045. Favorite Color Stripe (30)//按照普通的算法实现,居然超时还有错误,不明白啊???//wrong answer#include #include #include using namespace std;int main(){ int n; int m; int l; int color[205]; //vector str

2015-03-16 08:29:22 448

原创 PAT 1041. Be Unique (20)

//1041#includeint main(){ int n; int i; int a; int num[100008]; int flag[10008]; int j; int k = 0; int tag = 0; scanf("%d",&n); for(i=0;i<=1000;i++) { flag[i] = 0; } for(i=0;i<n

2015-03-14 11:36:31 428

原创 PAT 1040. Longest Symmetric String (25)

//1040//1040. Longest Symmetric String (25)#include #include #include #include using namespace std;int main(){ char str[1001]; gets(str); int len = strlen(str); int i = 0; char center;

2015-03-14 11:33:54 526

原创 PAT 1039. Course List for Student (25)

//1039. Course List for Student (25)//waiting//请记住用scanf和printf, 超时千万要找cin和cout好不好。。。//accept#include #include #include using namespace std;//typedef struct//{// bool course[2505];// int

2015-03-14 11:32:57 407

原创 PAT 1032. Sharing (25)

///* 方法一 accepted使用flag的方法,第一次遍历第一个链表,标记经过的flag为true;再遍历第二个链表,如果有flag已经为true则表示为所求的结果。*//* 方法二:第五个case错误,23分。后面注释的代码是直接将所有的next都保存到一个数组里面,进行查找出现两次的数据,即为重复出现的结果。但是这种方法,不能够排除无效的节点,所以

2015-03-14 11:32:10 556

原创 PAT 1034. Head of a Gang (30)

//1034. Head of a Gang (30)//#include "stdafx.h"//case 3 and case 5一直无法通过:主要是没有对结果进行排序//比较简单的dfs算法了#include #include #include using namespace std;int Num(string x){ int i; return (x[0]

2015-03-14 11:29:53 589

原创 PAT 1030 最短路径

//1030 最短路径#include #include using namespace std;int Dist[505 ][505] = {0};int Cost[505][505] = {0};int N, M, S, D;int CurrDis = 0;int ShortDis = 10000;int visit[505] = {0};vector CurRoad;

2015-03-14 11:27:37 287

原创 PAT 1029 Median (25)

//1029//注意一个数组进行完毕的问题,以及数组要定义为1000001而不是1000000#includelong int a[1000001],b[1000001];int main(){int m,n;int i,j;int count;//int flag;scanf("%d",&m);for(i=0;i{

2015-03-14 11:27:30 596

原创 PAT 1028. List Sorting (25)

//1028. List Sorting (25)//果然cin cout就会超时间啊//acc#include #include #includeusing namespace std;int N, C;typedef struct{ char id[7]; char name[9]; int score;}Stu;typedef struct{}StuNa

2015-03-14 11:25:12 291

原创 PAT 1025. PAT Ranking (25)

//1025. PAT Ranking (25)//acc#include #include #include using namespace std;typedef struct{ char name[14]; int score; int index;}Student;bool cmp( Student stu1, Student stu2){ if (st

2015-03-14 11:23:59 248

原创 PAT 1022. Digital Library (30)

//1022. Digital Library (30)#include "stdafx.h"//注意split函数的用法,即将一个字符串按照“ ”将其分开。//算法思想什么的很简单,和其他学生成绩排序的一样,主要就是用stl的sort函数//最后三个case老通不过,主要是不能够对结果建立一个结构体都保存起来,这样会超内存空间。//正确做法是:每当输入一个测试用例直接处理进行输出就

2015-03-14 11:22:26 259

原创 PAT 1021. Deepest Root (25)

//1021. Deepest Root (25)//第二个case是测试N =0 的情况#include #include #include #include using namespace std;vector Road[10005];int VisitedNum = 0;bool visit[10005] = {false};int N;queue q;int c

2015-03-14 10:46:15 275

原创 PAT 1020. Tree Traversals (25)

//1020. Tree Traversals (25)//递归//将层次遍历存储在数组里面就ok//accept#include #include using namespace std;int PostOrder[31];int InOrder[31];int result[35][35] = {0};int index[35] = {0};int level = 0;

2015-03-14 10:42:53 273

原创 PAT 1017. Queueing at Bank (25)

////1017. Queueing at Bank (25)// accept#include #include using namespace std;typedef struct { int second; int time;}Record;bool cmp(Record r1, Record r2){ if (r1.second == r2.second)

2015-03-14 10:39:19 354

原创 PAT 1016. Phone Bills (25)

//1016. Phone Bills (25)//accept#include #include #include using namespace std;typedef struct { char name[21]; int month; int day; int hour; int minute; bool state;//state = true: on-lin

2015-03-14 10:36:36 325

原创 PAT 1015. Reversible Primes (20)

//1015. Reversible Primes (20)//acc#include using namespace std;int Prime( int x ){ int i; if(x==1) return 0; for (i =2;i<=x/2;i++) { if (x%i == 0) { return 0; } } return 1;}

2015-03-14 10:34:23 241

原创 PAT 1014. Waiting in Line (30)

//1014. Waiting in Line (30)/* 解题思路: 对每个要加入队列的人进行以下两类考虑: 1)找到长度最短的队列,将当前考虑的元素加入进去。 2)如果队列长度都已经满的情况下,找到最先出来的元素,pop出来,然后将新的元素push进去。 特点: 排队题基本不需要考虑超时;*//* 有三个case的测试点是: 注意条件是要在17:0

2015-03-14 10:32:29 640

原创 PAT 1013. Battle Over Cities (25)

//1013. Battle Over Cities (25)//这道题主要思路是,删除了某个城市节点后,剩下的城市可以分作几部分(假设N部分),则需要组成的路线是N-1就可以将所有城市相连。//采用dfs将所有顶点遍历,判断可以分为的组即可。//acc#includeusing namespace std;bool Road[1005][1005] = {false}; bool

2015-03-14 10:30:07 254

原创 PAT 1012. The Best Rank (25)

////1012. The Best Rank (25)//acc//注意名次相同的情况。。。#include #include #include using namespace std;typedef struct{ char id[7]; int c; int m; int e; float a;}Student;bool cmp( Student s1,

2015-03-14 10:28:35 241

原创 PAT 1009. Product of Polynomials (25)

//1009. Product of Polynomials (25)//acc#include#include #include using namespace std;typedef struct{int e;float c;}poly;int main(){int k1,k2;cin >> k1;poly a[10], b[

2015-03-14 10:24:46 296

原创 PAT 1007. Maximum Subsequence Sum (25)

Given a sequence of K integers { N1, N2, ..., NK }. A continuous subsequence is defined to be { Ni, Ni+1, ..., Nj } where 1 Maximum Subsequence is the continuous subsequence which has the largest su

2015-03-14 10:19:02 318

原创 PAT 1004. Counting Leaves (30)

#include #include #include using namespace std;vector ID[105];int result[105] = {0};int main(void){int N, M;scanf("%d %d", &N, &M);for(int i = 0;i{int id, k;int i

2015-03-13 20:38:04 370

原创 PAT 1003. Emergency (25)

As an emergency rescue team leader of a city, you are given a special map of your country. The map shows several scattered cities connected by some roads. Amount of rescue teams in each city and the l

2015-03-11 13:53:21 263

原创 PAT 1002. A+B for Polynomials (25)

This time, you are supposed to find A+B where A and B are two polynomials.InputEach input file contains one test case. Each case occupies 2 lines, and each line contains the information of a p

2015-03-11 13:50:56 313

原创 PAT 1001. A+B Format (20)

Calculate a + b and output the sum in standard format -- that is, the digits must be separated into groups of three by commas (unless there are less than four digits).InputEach input file cont

2015-03-11 13:49:35 381

深入浅出mfc(中文)

该文章提供Mfc编程技术。深入浅出的介绍了Mfc编程方式,适合初学mfc者学习,大家可以看看这个中文版的哦。

2012-04-13

空空如也

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

TA关注的人

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