- 博客(47)
- 资源 (14)
- 收藏
- 关注
原创 【PAT甲级】1055. The World's Richest (25)
注:本以为考察二分法,结果并不是( ´◔ ‸◔’)#include <stdio.h> #include <algorithm>#include <vector>#include <string.h>using namespace std;typedef struct People { char name[9]; int age; int worth;} Peop
2016-10-28 19:55:52 201
原创 【PAT甲级】1054. The Dominant Color (20)
#include <stdio.h>#include <vector>#include <algorithm>#define MAX 1<<26using namespace std;int color[MAX] = {0};bool cmp(int a, int b) { return color[a] > color[b];}int main(int argc, char
2016-10-28 17:39:18 200
原创 【PAT甲级】1053. Path of Equal Weight (30)
注:比较函数写得有点复杂#include <stdio.h>#include <deque>#include <algorithm>#include <cmath>using namespace std;typedef struct Node { int key; int left; int right;} Node;Node tree[101];int n,
2016-10-28 17:25:09 186
原创 【PAT甲级】1052. Linked List Sorting (25)
注:如果链表为空,输出 “0 -1”#include <stdio.h>#include <deque>#include <algorithm>#define INC 100000#define MAX 200001using namespace std;int main(int argc, char *argv[]) { int n, start; scanf("%d %
2016-10-28 00:34:11 304
原创 【PAT甲级】1051. Pop Sequence (25)
#include <stdio.h>#include <stack>#include <deque>using namespace std;int main(int argc, char *argv[]) { int m, n, k, a; scanf("%d %d %d", &m, &n, &k); while (k--) { stack<int> s;
2016-10-27 22:49:53 202
原创 【PAT甲级】1050. String Subtraction (20)
#include <stdio.h>#include <string.h>int main(int argc, char *argv[]) { char a[10001]; char b[10001]; int map[1000] = {0}; gets(a); int al = strlen(a); gets(b); int bl = st
2016-10-26 23:23:33 244
原创 【PAT甲级】1049. Counting Ones (30)
#include <stdio.h>#include <cmath>int f(int a);int a[11] = {0};int main(int argc, char *argv[]) { int n; scanf("%d", &n); int i, j; int cnt = 0; int tmp = n; while (tmp > 0)
2016-10-26 22:58:48 185
原创 【PAT甲级】1048. Find Coins (25)
#include <stdio.h>int main(int argc, char *argv[]) { int n, m; int face[501] = {0}; //vector<int> v; scanf("%d %d", &n, &m); int i; for (i = 0; i < n; i++) { int tmp;
2016-10-26 19:08:57 176
原创 【PAT甲级】1047. Student List for Course (25)
#include <stdio.h>#include <vector>#include <stdlib.h>#include <algorithm>using namespace std;int getId(char *a) { int sum = (a[0]-'A')*26*26*10+(a[1]-'A')*26*10+(a[2]-'A')*10+(a[3]-'0');
2016-10-26 18:28:44 248
原创 【PAT甲级】1046. Shortest Distance (20)
#include <stdio.h>#include <cstdlib>using namespace std;int main(int argc, char *argv[]) { int n; int i, j, k; scanf("%d", &n); int *a = new int[n + 1]; a[0] = 0; for (i = 1; i
2016-10-26 15:52:29 207
原创 【PAT甲级】1045. Favorite Color Stripe (30)
动态规划:最长非连续子序列类似题目 注:最后两个测试用例容易超时,需要对算法进行优化#include <stdio.h>#include <string.h>int n, m, l;int in[201];int order[201][201];int getLongest(int *a, int *b, int m, int l);int main(int argc, char *arg
2016-10-26 14:58:56 280
原创 【PAT甲级】1044. Shopping in Mars (25)
注:推荐用二分法;这里用的是普通优化方法。注2:第二个测试用例不过是因为MAX取小了。#include <stdio.h>#include <deque>#define MAX 999999999 using namespace std;typedef struct Pair { int first; int second;} Pair;int main(int argc,
2016-10-25 12:40:18 257
原创 【PAT甲级】1043. Is It a Binary Search Tree (25)
注:在buildTree递归中,需要用malloc分配Node空间,并将left和right赋值为NULL。#include <stdio.h>#include <algorithm>#include <stdlib.h>using namespace std;int n;int a[1001];int b[1001];typedef struct Node { int key
2016-10-24 22:27:15 152
原创 【PAT甲级】1042. Shuffling Machine (20)
#include <stdio.h>#define N 54int main(int argc, char* argv[]) { int k; scanf("%d", &k); int i, j; int a[N + 1] = {0}; int b[N + 1] = {0}; for (i = 1; i <= N; i++) { sc
2016-10-24 18:30:09 320
原创 【PAT甲级】1041. Be Unique (20)
#include <stdio.h>using namespace std;int main(int argc, char *argv[]) { int n; scanf("%d", &n); int i, j, k; int cnt[100001] = {0}; int *a = new int[n]; for (i = 0; i < n; i++
2016-10-24 17:09:49 186
原创 【PAT甲级】1040. Longest Symmetric String (25)
注:找不到Symmetric String时,打印长度为1。#include <stdio.h>#include <string.h>#include <string>int main(int argc, char* argv[]) { char a[1001]; gets(a); int n = strlen(a); int h, e; int lh, l
2016-10-24 16:44:37 175
原创 【PAT甲级】1039. Course List for Student (25)
注:string, cin/cout, deque, map均超时,因此换成scanf, vector,并使用数组映射,提高效率。#include <stdio.h>#include <algorithm>#include <vector>using namespace std;int n, k;vector<int> m[26*26*26*10];int main(int argc, c
2016-10-24 15:14:07 239
原创 【PAT甲级】1038. Recover the Smallest Number (30)
注:比较大小时要用长整型注2:注意数字片段中可能存在全为0的片段,要跳过这些开头片段,并对第一个非零片段进行前几位0消除;如果片段全为0,则输出0;#include <stdio.h>#include <deque>#include <algorithm>#include <cmath>#include <string.h>using namespace std;typedef str
2016-10-24 11:04:45 180
原创 【PAT甲级】1037. Magic Coupon (25)
#include <stdio.h>#include <deque>#include <algorithm>using namespace std;bool com(long long a, long long b) { return a > b;}int main(int argc, char *argv[]) { deque<long long> a; deque
2016-10-23 21:44:05 268
原创 【PAT甲级】1036. Boys vs Girls (25)
#include <stdio.h>#include <algorithm>#include <deque>using namespace std;typedef struct Stu { char name[11]; char gender; char course[11]; int grade;} Stu;deque<Stu> q;bool com(
2016-10-23 21:07:20 224
原创 【PAT甲级】1035. Password (20)
#include <iostream>#include <string>#include <deque>using namespace std;typedef struct Acc { string name; string ps;} Acc;deque<Acc> out;int main(int argc, char *argv[]) { int n;
2016-10-23 20:43:00 198
原创 【PAT甲级】1034. Head of a Gang (30)
注: Gang的成员数要达到两人以上。#include <stdio.h>#include <iostream>#include <map>#include <string.h>#include <string>#include <deque>#include <algorithm>using namespace std;typedef struct Gang { int he
2016-10-23 16:04:57 224
原创 【PAT甲级】1033. To Fill or Not to Fill (25)
陷阱:没有距离为0加油站,则汽车无法行驶( ´◔ ‸◔’)#include <stdio.h>#include <algorithm>using namespace std;typedef struct Sta { double price; double dist; double gas_ds;} Sta;double c_max;double d;doubl
2016-10-21 18:15:28 289
原创 【PAT甲级】1032. Sharing (25)
注:这道题除了必要的输入数据外,还可能有杂七杂八的干扰,比如无用的链接、重复的链接等。#include <stdio.h>int main(int argc, char *argv[]) { int list[100000] = {0}; int n; int arr1; int arr2; int set[100000] = {0}; int i;
2016-10-20 20:46:47 253
原创 【PAT甲级】1031. Hello World for U (20)
#include <stdio.h>#include <string.h>int main(int argc, char *argv[]) { int n, n1, n2, n3; char a[81]; scanf("%s", a); n = strlen(a); if (n % 2 == 0) n2 = 4; else n2 = 3; n
2016-10-20 11:41:11 249
原创 【PAT甲级】1030. Travel Plan (30)
#include <stdio.h>#define MAX 9999999typedef struct Ci { int dist; int cost;} Ci;Ci map[501][501];int n, m, s, d;int main(int argc, char *argv[]) { scanf("%d %d %d %d", &n, &m, &s, &d);
2016-10-20 11:12:57 241
原创 【PAT甲级】1029. Median (25)
#include <stdio.h>#include <algorithm>#include <deque>using namespace std;deque<long> dq[2];deque<long> q;int main(int argc, char *argv[]) { for (int i = 0; i < 2; i++) { int m;
2016-10-19 23:29:58 195
原创 【PAT甲级】1028. List Sorting (25)
#include <stdio.h>#include <deque>#include <string.h>#include <algorithm>using namespace std;typedef struct Stu { int id; char name[9]; int grade;} Stu;deque<Stu> student;bool com_i
2016-10-19 22:56:23 163
原创 【PAT甲级】1027. Colors in Mars (20)
#include <stdio.h>char toChar(int i);int main(int argc, char *argv[]) { int a[3]; scanf("%d %d %d", &a[0], &a[1], &a[2]); int rgb[3][2]; int i; for (i = 0; i < 3; i++) { rgb
2016-10-19 22:35:36 219
原创 【PAT甲级】1026. Table Tennis (30)
注:vip顾客面临多桌选择时,优先选择vip球桌。注2:非vip顾客有多桌选择时,选id号最小的球桌。注3:只有vip桌空出来的时候,vip顾客才能插队;非vip球桌空出来时,顾客(包括vip与非vip)中到达最早的先选。#include <stdio.h>#include <deque>#include <algorithm>#define OPEN_TIME 8 * 3600#def
2016-10-19 21:11:54 283
原创 【PAT甲级】1025. PAT Ranking (25)
#include <stdio.h>#include <iostream>#include <deque>#include <algorithm>#include <string.h>using namespace std;typedef struct Testee { string num; int loca; int score; int rank;
2016-10-18 10:50:25 218
原创 【PAT甲级】1024. Palindromic Number (25)
#include <stdio.h>#include <stdio.h>#include <string.h>char in[200];int num[200] = {0};int k;void add(int *a, int &n);bool isPa(int *a, int n);int main(int argc, char *argv[]) { scanf("%s %d
2016-10-17 23:12:15 239
原创 【PAT甲级】1023. Have Fun with Numbers (20)
#include <stdio.h>#include <string.h>int main(int argc, char *argv[]) { int i, k; char in[23]; int num[23] = {0}; int map[10] = {0}; int map2[10] = {0}; scanf("%s", in); k
2016-10-17 22:39:09 203
原创 【PAT甲级】1022. Digital Library (30)
#include <iostream>#include <iomanip>#include <sstream>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <string>#include <map>#include <set>using namespace std;int n;int m;m
2016-10-17 21:34:34 326
原创 【PAT甲级】1021. Deepest Root (25)
注:要考虑时间空间效率问题:使用邻接表,并减少使用dfs的次数(原来为n次dfs,后面改为2次)。#include <stdio.h>#include <string.h>#include <deque>#include <algorithm>using namespace std;int n;deque<int> map[10001];int set[10001];void dfs
2016-10-16 15:51:06 248
原创 【PAT甲级】1020. Tree Traversals (25)
注:在levelTraverse递归中,需要用malloc分配Node空间,并将left和right赋值为NULL。#include <stdio.h>#include <deque>#include <stdlib.h>using namespace std;typedef struct Node { int key; Node* left; Node* right
2016-10-15 12:59:19 154
原创 【PAT甲级】1018. Public Bike Management (30)
注:这里用到了Dijkstra和DFS注2:需要找出所有路径,然后才能选择最小的minNeed,minTake注3:need(需要的bikes数量)要进行累加注4:相同长度的最短路径,选择need最少的;如果这时need也相同,则选择take最少的;#include <stdio.h>#include <string.h>#include <deque>#include <stdlib
2016-10-14 16:14:01 285
原创 【PAT甲级】1019. General Palindromic Number (20)
注:特殊情况 n == 0.#include <stdio.h>int main(int argc, char *argv[]) { int n, b; scanf("%d %d", &n, &b); if (n == 0) { printf("Yes\n0\n"); return 0; } int i; int a[1
2016-10-14 13:33:31 242
原创 【PAT甲级】1017. Queueing at Bank (25)
注:只要顾客在工作时间到达,那么即使轮到他的时候银行已经下班,仍然要给他办理。#include <stdio.h>#include <algorithm>#include <vector>#define OPEN_TIME 8 * 3600#define CLOSE_TIME 17 * 3600using namespace std;typedef struct Cus { int
2016-10-13 15:54:54 359
原创 【POJ】1005. I Think I Need a Houseboat
#include <stdio.h>#include <cmath>#define pi 3.1415926536using namespace std;int main(int argc, char *argv[]) { int n; float x, y; scanf("%d", &n); float preR2, R2; int i; int
2016-10-12 22:42:52 215
【pdf kindle打包】Naked Statistics Stripping the Dread From the Data
2018-12-05
ESL英文版+中文版+答案 The Elements of Statistical Learning 统计学习基础
2018-05-28
Scikit-learn Cookbook.pdf 英文版 + 中文版
2018-05-14
Pattern Recognition And Machine Learning英文+中文+完整答案 模式识别与机器学习
2018-05-07
Pattern Recognition and Machine Learning 模式识别与机器学习 中文版
2018-05-07
Introduction to Scorecard for FICO Model Builder 英文
2018-04-16
The Little SAS Book for Enterprise Guide 4.2 英文版
2018-04-11
动态规划:从新手到专家 Hawstein
2016-10-26
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人