
PAT
文章平均质量分 67
hale1007
ZJUCS小硕一枚,进阶中的菜鸟
展开
-
PAT (Advanced) 1016. Phone Bills (25)
#include #include #include #include #include using namespace std;struct Call{ int month, dd, hh, mm; string tag;};bool cmp(const Call &a, const Call &b){ if (a.dd != b.dd) return a.d原创 2014-09-03 20:22:28 · 480 阅读 · 0 评论 -
PAT (Advanced) 1043. Is It a Binary Search Tree (25)
#include #include using namespace std;struct Node{ Node *left, *right; int key;}node[2005];int cnt = 0;Node *create(){ node[cnt].left = node[cnt].right = nullptr; return &node[cnt++];原创 2014-09-05 15:41:21 · 475 阅读 · 0 评论 -
PAT (Basic) 1006~1010
1006. 换个格式输出整数 (15)#include #include using namespace std;int main(){ int n; cin >> n; int b = n / 100; int s = n / 10 % 10; int g = n % 10; for (int i = 0; i < b; i++) cout << "B";原创 2014-03-04 19:28:22 · 588 阅读 · 0 评论 -
PAT (Advanced) 1062. Talent and Virtue (25)
#define _CRT_SECURE_NO_WARNINGS#include #include #include #include using namespace std;struct Man{ int id; int virtue; int talent; int total; int type;};vector man;bool cmp(const Ma原创 2014-03-02 13:18:35 · 811 阅读 · 0 评论 -
PAT (Advanced) 1025. PAT Ranking (25)
水题一个,但是因为排序规则看得不够仔细,有个6分测试点始终通不过,耗费了大量时间,悲剧。以下完整AC代码:#define _CRT_SECURE_NO_WARNINGS#include #include #include #include using namespace std;struct Testee{ string id; int score; int loc原创 2014-03-02 16:21:08 · 631 阅读 · 0 评论 -
PAT (Advanced) 1075. PAT Judge (25)
下面这个代码最后一个3分测试样例始终无法通过,搞得人非常无语。如果你发现了其中的bug,请留言告诉我。非常感谢!#define _CRT_SECURE_NO_WARNINGS#include #include using namespace std;struct User{ int user_id; int rank; int total_score; int pro原创 2014-03-10 20:45:10 · 730 阅读 · 0 评论 -
PAT (Advanced) 1069. The Black Hole of Numbers (20)
#include #include #include using namespace std;int make_big(int n){ int ary[4]; ary[0] = n / 1000; ary[1] = n / 100 % 10; ary[2] = n / 10 % 10; ary[3] = n % 10; sort(ary, ary + 4); int r原创 2014-03-02 00:54:45 · 691 阅读 · 0 评论 -
PAT (Advanced) 1063. Set Similarity (25)
最后一个4分测试点老是超时,无奈网上搜解题报告。注释里有我之前的方法,注意注释里的merge和现在的merge含义不一样。相应的最后输出公式也要修改。利用set_intersection更潇洒飘逸~#define _CRT_SECURE_NO_WARNINGS#include #include #include #include #include #includ原创 2014-03-03 16:15:45 · 628 阅读 · 0 评论 -
PAT (Advanced) 1012. The Best Rank (25)
#define _CRT_SECURE_NO_WARNINGS#include #include #include #include #include using namespace std;struct Student{ string id; int c, m, e, a; int rank[4];// a, c, m, e};vector student;boo原创 2014-03-02 22:23:11 · 604 阅读 · 0 评论 -
PAT (Advanced) 1081. Rational Sum (20)
#include using namespace std;long long gcd(long long a, long long b){ long long r; while (b > 0) { r = a % b; a = b; b = r; } return a;}long long lcm(long long a, long long b){ re原创 2014-08-26 12:21:54 · 647 阅读 · 0 评论 -
PAT (Advanced) 1083. List Grades (25)
#include #include #include #include using namespace std;struct Student{ string name; string id; int grade;};bool cmp(const Student &a, const Student &b){ if (a.grade != b.grade) retu原创 2014-08-26 22:49:01 · 506 阅读 · 0 评论 -
PAT (Advanced) 1057. Stack (30)
#include #include #include #include #include using namespace std;multiset small, big;stack s;int mid;void adjust(){ if (small.size() > big.size() + 1) { auto it = small.end(); --it;原创 2014-09-03 13:17:45 · 476 阅读 · 0 评论 -
PAT (Advanced) 1017. Queueing at Bank (25)
#define _CRT_SECURE_NO_WARNINGS#include #include #include using namespace std;struct Customer{ int arrive_time, cost_time;};bool cmp(const Customer &a, const Customer &b){ return a.arriv原创 2014-09-03 22:10:10 · 523 阅读 · 0 评论 -
PAT (Advanced) 1014. Waiting in Line (30)
#include #include #include using namespace std;const int INF = 0x6fffffff;struct customer{ int process, leave;}cus[1005];int main(){ int n, m, k, q; cin >> n >> m >> k >> q; for (int原创 2014-09-03 16:04:29 · 446 阅读 · 0 评论 -
PAT (Advanced) 1038. Recover the Smallest Number (30)
#include #include #include #include using namespace std;bool cmp(const string &a, const string &b){ return (a + b) < (b + a);}int main(){ int n; cin >> n; vector num(n); for (int i =原创 2014-09-02 21:45:17 · 393 阅读 · 0 评论 -
PAT (Advanced) 1033. To Fill or Not to Fill (25)
#include #include #include using namespace std;struct gas_station{ double price, dist;}gs[501];bool cmp(const gas_station &a, const gas_station &b){ return a.dist < b.dist;}int main()原创 2014-09-02 21:14:05 · 452 阅读 · 0 评论 -
PAT (Advanced) 1030. Travel Plan (30)
#include #include using namespace std;const int INF = 0x6fffffff;const int MAX = 501;int map[MAX][MAX], value[MAX][MAX], dist[MAX], cost[MAX], pre[MAX], visit[MAX];stack path;void init(int原创 2014-09-01 18:40:42 · 765 阅读 · 0 评论 -
PAT (Advanced) 1034. Head of a Gang (30)
#include #include #include #include #include using namespace std;map > calls;map visit;map weight;map result;int cnt, totalweight;string head;void dfs(string str){ visit[str] = true;原创 2014-08-29 11:37:31 · 417 阅读 · 0 评论 -
PAT (Advanced) 1048. Find Coins (25)
#include #include #include using namespace std;int main(){ int n, m; cin >> n >> m; vector values(n); for (int i = 0; i < n; i++) { cin >> values[i]; } sort(values.begin(), values.end(原创 2014-08-29 10:08:16 · 447 阅读 · 0 评论 -
PAT (Advanced) 1032. Sharing (25)
#define _CRT_SECURE_NO_WARNINGS#include #include using namespace std;struct Node{ char data; int next;}node[100005];int main(){ int head1, head2, n; cin >> head1 >> head2 >> n; if (hea原创 2014-03-03 13:55:26 · 682 阅读 · 1 评论 -
PAT (Advanced) 1054. The Dominant Color (20)
方法一:使用map#define _CRT_SECURE_NO_WARNINGS#include #include #include using namespace std;map mp;map ::iterator it;int main(){ int m, n; cin >> m >> n; for (int i = 0; i < m * n; i++)原创 2014-03-02 14:26:17 · 544 阅读 · 0 评论 -
PAT (Advanced) 1070. Mooncake (25)
#include #include #include #include using namespace std;const int MAX = 1010;struct Mooncake{ double inventory; double price; double cp; // cost performance bool operator < (const Moonc原创 2014-03-04 12:59:13 · 723 阅读 · 0 评论 -
PAT (Basic) 1011~1015
1011. A+B和C (15)#include using namespace std;int main(){ int n; cin >> n; for (int i = 0; i < n; i++) { long long a, b, c; cin >> a >> b >> c; cout << "Case #" << i + 1 << ": "; if原创 2014-03-04 19:36:42 · 556 阅读 · 0 评论 -
PAT (Basic) 1001~1005
1001. 害死人不偿命的(3n+1)猜想 (15)#include using namespace std;int main(){ int n; cin >> n; int tot = 0; while (n != 1) { if (n % 2 == 0) n /= 2; else n = (3 * n + 1) / 2; tot++; } c原创 2014-03-04 19:19:05 · 595 阅读 · 0 评论 -
PAT (Advanced) 1024. Palindromic Number (25)
#include #include #include using namespace std;bool is_palindromic(string s){ int i = 0, j = s.length() - 1; while (i < j) { if (s[i] != s[j]) return false; i++; j--; } return tru原创 2014-03-06 18:24:36 · 658 阅读 · 0 评论 -
PAT (Advanced) 1055. The World's Richest (25)
#define _CRT_SECURE_NO_WARNINGS#include #include #include #include using namespace std;struct People{ string name; int age; int net_worth;};vector people;bool cmp(const People &a, cons原创 2014-03-07 18:35:55 · 707 阅读 · 0 评论 -
PAT (Advanced) 1071. Speech Patterns (25)
#include #include #include #include using namespace std;map mp;map ::iterator it;bool is_alphanumerial(char c){ return c >= '0' && c = 'a' && c = 'A' && c <= 'Z';}int main(){ string i原创 2014-03-07 16:20:22 · 619 阅读 · 0 评论 -
PAT (Advanced) 1076. Forwards on Weibo (30)
#include #include using namespace std;const int MAX = 1000;bool edge[MAX][MAX];bool visited[MAX];int queue[MAX];int BFS(int start, int n, int level){ int res = 0; int front = 0, rear = 1,原创 2014-03-10 21:03:57 · 698 阅读 · 0 评论 -
PAT (Advanced) 1077. Kuchiguse (20)
随便写了个,比较啰嗦。下次有机会找找好的方法。#include #include #include #include #include using namespace std;vector vs;int main(){ int N; cin >> N; getchar(); while (N--) { string str; getline(ci原创 2014-03-24 23:52:33 · 899 阅读 · 0 评论 -
PAT (Advanced) 1079. Total Sales of Supply Chain (25)
#include #include #include #include using namespace std;const int MAX_N = 100000;int N;double P, r, sum = 0.0;struct Node{ vector child; int level, sale;}node[MAX_N];queue Q;int main原创 2014-03-26 10:50:26 · 641 阅读 · 0 评论 -
PAT (Basic) 1016~1020
1016. 部分A+B (15)#include #include using namespace std;int main(){ string a, b; int da, db; int pa = 0, pb = 0; cin >> a >> da >> b >> db; int len1 = a.length(); int len2 = b.length();原创 2014-03-04 19:44:17 · 664 阅读 · 0 评论 -
PAT (Advanced) 1074. Reversing Linked List (25)
根据评论里的那种思路写的一个代码。这种思路很简单,用一个数组保存每个节点的地址,然后对数组进行reverse。这个题目还可以运用map,也非常方便。#include#include#include using namespace std;int node[100002][2];int main(){ int list[100002]; int i; int st,原创 2014-03-05 21:40:31 · 2488 阅读 · 13 评论 -
PAT (Advanced) 1061. Dating (20)
#include #include using namespace std;int main(){ string s1, s2, s3, s4; cin >> s1 >> s2 >> s3 >> s4; int pos = 0; while (!(s1[pos] == s2[pos] && s1[pos] >= 'A' && s1[pos] <= 'G')) pos++;原创 2014-03-04 14:29:26 · 691 阅读 · 0 评论 -
PAT (Basic) 1021~1025
1021. 个位数统计 (15)#include #include #include using namespace std;int main(){ map mp; string str; cin >> str; int len = str.length(); for (int i = 0; i < len; i++) { int index = str[i] -原创 2014-03-05 23:34:02 · 658 阅读 · 0 评论 -
PAT (Advanced) 1046. Shortest Distance (20)
#include #include using namespace std;int main(){ int n; cin >> n; int tot = 0; vector dis(n+1); dis[0] = 0; int tmp; for (int i = 1; i <= n; i++) { cin >> tmp; dis[i] = dis[i - 1] +原创 2014-03-06 23:39:45 · 550 阅读 · 0 评论 -
PAT (Advanced) 1035. Password (20)
#include #include #include using namespace std;struct Account{ string id, pswd;};string modify(string s){ string res; int len = s.length(); for (int i = 0; i < len; i++) { if (s[i] =原创 2014-03-07 12:43:53 · 620 阅读 · 0 评论 -
PAT (Advanced) 1052. Linked List Sorting (25)
#define _CRT_SECURE_NO_WARNINGS#include #include #include using namespace std;struct Node{ int addr, key, next;}node[100000];vector listNode;bool cmp(const Node &a, const Node &b){ ret原创 2014-03-07 21:12:45 · 627 阅读 · 0 评论 -
PAT (Advanced) 1078. Hashing (25)
注意是平方探测,1^2,2^2,3^2.....其中要平方的数小于TSize,不然探测没法停止,我之前在这里卡着过不了。#define _CRT_SECURE_NO_WARNINGS#include #include #include #include #include using namespace std;bool is_prime(int n){ if原创 2014-03-25 11:17:23 · 615 阅读 · 0 评论 -
PAT (Advanced) 1073. Scientific Notation (20)
#define _CRT_SECURE_NO_WARNINGS#include #include #include using namespace std;int main(){ string raw; cin >> raw; if (raw[0] == '-') cout << '-'; string s(raw.begin() + 1, raw.end()); i原创 2014-03-01 22:58:56 · 1151 阅读 · 0 评论 -
PAT (Advanced) 1041. Be Unique (20)
#include #include using namespace std;int input[100005];int times[100005];int main(){ int n; cin >> n; int tmp; for (int i = 0; i < n; i++) { cin >> input[i]; times[input[i]]++; }原创 2014-03-06 18:19:23 · 602 阅读 · 0 评论