![](https://img-blog.csdnimg.cn/20201014180756724.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
PAT甲级
pacmoc
用代码托起我的不切实际
展开
-
1003 Emergency (25)
#include <iostream>#include <algorithm>using namespace std;int main(int argc, const char * argv[]) { //基本初始化 const int inf = 99999999; int e[500][500] = {inf};//e表示两个城市之间是否...原创 2018-01-23 19:58:54 · 174 阅读 · 0 评论 -
1002. A+B for Polynomials (25)
#include <iostream>#include <algorithm>using namespace std;int main(int argc, const char * argv[]) { // insert code here... int k; double a[1001]; fill(a, a + 1001, 0);...原创 2017-06-02 19:20:19 · 157 阅读 · 0 评论 -
1005. Spell It Right (20)
#include <iostream>using namespace std;int main(int argc, const char * argv[]) { string s; cin >> s; int sum = 0, len = (int)s.length(); for (int i = 0; i < len;...原创 2018-01-23 20:00:30 · 103 阅读 · 0 评论 -
1006. Sign In and Sign Out (25)
简析:(1)求第一个登录的人和最后一个登出的人; (2)m:记录的个数; (3)记录:id 登录的时间 登出的时间(hh:mm:ss; id为string,少于15字符)(4)关键在于如何比较时间,化为整数比 h*3600 + m*60 + s; (5)采用结构体, id, t1, t2;题目很简单,一次ac.#include <iostream>using namespace st...原创 2018-01-23 22:11:44 · 114 阅读 · 0 评论 -
1007. Maximum Subsequence Sum (25)
简析:求最大子列和,并输出其首末元素。在线处理,关键在于求首末元素。本题囧,16年9月做出来过,现在15分钟只能拿到22分,有一个测试点过不了。所以现在的答案是当时的。#include <iostream>using namespace std;int main(int argc, const char * argv[]) { int n, N = 0, sum = 0,...原创 2018-01-24 00:23:16 · 105 阅读 · 0 评论 -
1008. Elevator (20)
简析:10分钟内ac,没有难度。#include <iostream>using namespace std;int main(int argc, const char * argv[]) { int n, f0 = 0, f1, sum = 0; cin >> n; int a[n]; for (int i = 0; i < n...原创 2018-01-24 00:39:03 · 106 阅读 · 0 评论 -
1009. Product of Polynomials (25)
#include <iostream>using namespace std;int main(int argc, const char * argv[]) { double a[1001] = {0}, b[1001] = {0}, p[2001] = {0}; int m, n; scanf("%d", &m); double c; ...原创 2018-01-24 11:14:28 · 110 阅读 · 0 评论 -
1011. World Cup Betting (20)
简析:关键是W T L的对应。#include <iostream>using namespace std;int main(int argc, const char * argv[]) { char c1 = '\0', c2 = '\0', c3 = '\0'; double a, b, c; double t1 = 0, t2 = 0, t3 = 0...原创 2018-01-24 21:37:57 · 128 阅读 · 0 评论 -
1015. Reversible Primes (20)
#include <iostream>#include <cmath>using namespace std;/* 要求:(1)判断该数是否为素数(2)判断该数基于d进制的逆序的十进制数是否为素数 思路:(1)IsPrime判断素数 (2)基于d进制的逆序,并转换为十进制 */bool IsPrime(int n){ if(n <= 1) ...原创 2018-01-24 23:57:31 · 147 阅读 · 0 评论 -
1019. General Palindromic Number (20)
A number that will be the same when it is written forwards or backwards is known as a Palindromic Number. For example, 1234321 is a palindromic number. All single digit numbers are palindromic numbers原创 2018-01-25 15:50:07 · 75 阅读 · 0 评论 -
1023. Have Fun with Numbers (20)
#include <iostream>#include <algorithm>using namespace std;int main(){ string s, sa, sb; cin >> s; sa = s; int flag = 0, ans = 1; for (int i = (int)s.length()...原创 2018-01-25 16:48:18 · 130 阅读 · 0 评论 -
1027. Colors in Mars (20)
People in Mars represent the colors in their computers in a similar way as the Earth people. That is, a color is represented by a 6-digit number, where the first 2 digits are for Red, the middle 2 dig原创 2018-01-25 17:26:01 · 84 阅读 · 0 评论 -
1031. Hello World for U (20)
Given any string of N (>=5) characters, you are asked to form the characters into the shape of U. For example, "helloworld" can be printed as:h de ll rlowoThat is, the characters must be pr原创 2018-01-25 18:05:52 · 109 阅读 · 0 评论 -
1128. N Queens Puzzle (20) 判断是否是对角线
The "eight queens puzzle" is the problem of placing eight chess queens on an 8×8 chessboard so that no two queens threaten each other. Thus, a solution requires that no two queens share the same row原创 2018-02-02 21:24:11 · 210 阅读 · 0 评论 -
1104. Sum of Number Segments (20) consecutive subsequence 每个数出现的次数
Given a sequence of positive numbers, a segment is defined to be a consecutive subsequence. For example, given the sequence {0.1, 0.2, 0.3, 0.4}, we have 10 segments: (0.1) (0.1, 0.2) (0.1, 0.2, 0.3原创 2018-02-03 01:08:00 · 110 阅读 · 0 评论 -
1100. Mars Numbers (20)
#include <iostream>#include <string>using namespace std;string mars0[14] = {"tret", "jan", "feb", "mar", "apr", "may", "jun", "jly", "aug&q原创 2018-02-04 03:42:23 · 102 阅读 · 0 评论 -
1101. Quick Sort (25)
#include <iostream>#include <cmath>using namespace std;int main(int argc, const char * argv[]) { int n; int a[100000], pivot[100000]; fill(pivot, pivot + 100000, 1); ci...原创 2018-02-04 04:28:19 · 92 阅读 · 0 评论 -
1092. To Buy or Not to Buy (20) simple
#include <iostream>using namespace std;int main(int argc, const char * argv[]) { // insert code here... string s0, s; cin >> s0 >> s; int cnt = 0; for (in...原创 2018-02-04 20:57:28 · 179 阅读 · 0 评论 -
1084. Broken Keyboard (20)
On a broken keyboard, some of the keys are worn out. So when you type some sentences, the characters corresponding to those keys will not appear on screen.Now given a string that you are supposed原创 2018-02-04 22:57:28 · 83 阅读 · 0 评论 -
1081. Rational Sum (20)
#include <iostream>using namespace std;long gcd(long a, long b){ while (a) { long t = a; a = b % a; b = t; } return b;}int main(int argc, const char * a...原创 2018-02-04 23:20:29 · 109 阅读 · 0 评论 -
1077. Kuchiguse (20) 思路相同 ******
The Japanese language is notorious for its sentence ending particles. Personal preference of such particles can be considered as a reflection of the speaker's personality. Such a preference is calle原创 2018-02-04 23:57:05 · 258 阅读 · 0 评论 -
1073. Scientific Notation (20) 棒棒的
Scientific notation is the way that scientists easily handle very large numbers or very small numbers. The notation matches the regular expression [+-][1-9]"."[0-9]+E[+-][0-9]+ which means that the in原创 2018-02-05 01:03:31 · 150 阅读 · 0 评论 -
1046. Shortest Distance (20)
The task is really simple: given N exits on a highway which forms a simple cycle, you are supposed to tell the shortest distance between any pair of exits.Input Specification:Each input file c原创 2018-02-05 02:03:08 · 100 阅读 · 0 评论 -
1035. Password (20)
To prepare for PAT, the judge sometimes has to generate random passwords for the users. The problem is that there are always some confusing passwords since it is hard to distinguish 1 (one) from l (L原创 2018-01-29 14:43:38 · 105 阅读 · 0 评论 -
1041 Be Unique (20)
#include <iostream>#include <string>#include <map>#include <vector>#include <algorithm>using namespace std; int main() { int n; cin >> n; vector<...原创 2018-01-29 15:34:00 · 138 阅读 · 0 评论 -
1042. Shuffling Machine (20)
Shuffling is a procedure used to randomize a deck of playing cards. Because standard shuffling techniques are seen as weak, and in order to avoid "inside jobs" where employees collaborate with gambler原创 2018-01-29 16:16:09 · 115 阅读 · 0 评论 -
1050. String Subtraction (20)
分析:很无奈,我想用python。实在是简单呀。python:s1 = raw_input()s2 = raw_input()for e in s2: if e in s1: s1 = s1.replace(e, '')print s1c++:#include <iostream>#include <string>#include <...原创 2018-01-29 21:32:28 · 108 阅读 · 0 评论 -
1054. The Dominant Color (20)
Behind the scenes in the computer's memory, color is always talked about as a series of 24 bits of information for each pixel. In an image, the color with the largest proportional area is called the d原创 2018-01-29 22:11:13 · 90 阅读 · 0 评论 -
1058. A+B in Hogwarts (20)
If you are a fan of Harry Potter, you would know the world of magic has its own currency system -- as Hagrid explained it to Harry, "Seventeen silver Sickles to a Galleon and twenty-nine Knuts to a Si原创 2018-01-29 22:53:42 · 100 阅读 · 0 评论 -
1061. Dating (20)
Sherlock Holmes received a note with some strange strings: "Let's date! 3485djDkxh4hhGE 2984akDfkkkkggEdsb s&hgsfdk d&Hyscvnm". It took him only a minute to figure out that those strange strings are a原创 2018-01-30 00:15:30 · 108 阅读 · 0 评论 -
1065. A+B and C (64bit) (20) 溢出
Given three integers A, B and C in [-263, 263], you are supposed to tell whether A+B > C.Input Specification:The first line of the input gives the positive number of test cases, T (Output原创 2018-01-30 01:16:19 · 151 阅读 · 0 评论 -
1069. The Black Hole of Numbers (20) string转int
#include <iostream>#include <algorithm>using namespace std;bool compare(char a, char b){ return a > b;}int main(int argc, const char * argv[]) { string s, a, b; cin >&g...原创 2018-01-30 02:27:13 · 124 阅读 · 0 评论 -
1103. Integer Factorization (30) dfs
#include <iostream>#include <cmath>#include <vector>using namespace std;int n, k, p, maxFacSum = -1; // n 和 k 几个数字 p阶数vector<int> v, ans, tempAns;void init(){//将1到n的每一...原创 2018-02-10 23:40:46 · 123 阅读 · 0 评论 -
1106. Lowest Price in Supply Chain (25) dfs
#include <iostream>#include <vector>#include <cmath>using namespace std;int n, mindepth = 9999999, minnum = 0;double p, r;vector<int> v[100001];void dfs(int index, int ...原创 2018-02-11 00:40:11 · 167 阅读 · 0 评论 -
1079. Total Sales of Supply Chain (25) dfs
#include <iostream>#include <vector>#include <algorithm>#include <cmath>using namespace std;vector<int> v[100001];vector<int> amount[100001];int n;double s...原创 2018-02-11 01:23:08 · 146 阅读 · 0 评论 -
1090. Highest Price in Supply Chain (25) dfs
#include <iostream>#include <vector>#include <cmath>using namespace std;int n, maxnum, maxdepth = 0, root = 0;double p, r;vector<int> v[100001];//存放树void dfs(int index...原创 2018-02-11 02:05:20 · 159 阅读 · 0 评论 -
1070. Mooncake (25)
#include <algorithm>#include <iostream>#include <vector>using namespace std;//思路: 用结构体存储月饼 里面存储 月饼的数量 价格 和单价//将月饼的单价进行排序//根据月饼的需求 依次卖出价格从高到低的月饼//终止条件为 某种月饼的数量大于还需要的月饼的数量 这时候...原创 2018-02-26 13:42:47 · 91 阅读 · 0 评论 -
1051. Pop Sequence (25)
//题目大意:给出栈的最大容量 数列的长度 测试样例的数量 判断每个测试序列是否能够由该栈得到//思路://1.使用stl中的stack stack的size按照题设条件确定 (1)按顺序将数字入栈 (2)栈顶元素等于当前出栈序列元素时 将栈中元素出栈 (3)当不相等时入栈//2.当超过栈的容量时 当元素全部入栈 而栈顶元素不等于当前出栈元素时 判断为NO (4)当全部元素入栈 出栈序列遍历...原创 2018-02-26 20:12:33 · 435 阅读 · 0 评论 -
1074. Reversing Linked List (25)
#include <iostream>#include <vector>#include <algorithm>using namespace std;struct node { int address, data, next;};const int NUM = 100001;node nodes[NUM];vector<nod...原创 2018-02-26 21:56:09 · 121 阅读 · 0 评论 -
1032. Sharing (25)
#include <iostream>using namespace std;/* 题目大意:求两个链表的首个共同结点的地址。如果没有,就输出-1 分析: 用结构体数组存储,node[i]表示地址为i的结点 key表示值,next为下一个结点的地址,flag表示第一条链表有没有该结点 遍历第一条链表,将访问过的结点的flag都标记为true, 当遍历第二条结点的时候,如...原创 2018-02-26 22:34:12 · 102 阅读 · 0 评论