
PAT
文章平均质量分 67
iteye_7173
这个作者很懒,什么都没留下…
展开
-
PAT1001 A+B Format
在一行中输入整数 a 和 b,用空格隔开(-1000000 <= a, b <= 1000000 )输出a+b的值,用千分位格式输出Sample Input-1000000 9Sample Output-999,991 python版本代码如下 import reimport sysdef fun(num): if num ...原创 2012-11-17 23:36:17 · 105 阅读 · 0 评论 -
PAT1023 Have Fun with Numbers
大数的相加 比较两个字符串中字符完全相同 Sample Input: 1234567899Sample Output:Yes2469135798 #include <iostream>#include <string>#include <vector>#include <io...原创 2012-11-21 23:55:21 · 102 阅读 · 0 评论 -
PAT1025 PAT Ranking
Sample Input:251234567890001 951234567890005 1001234567890003 951234567890002 771234567890004 8541234567890013 651234567890011 251234567890014 1001234567890012 85Sample Ou...原创 2012-11-22 23:51:45 · 133 阅读 · 0 评论 -
PAT1027 Colors in Mars
Sample Input15 43 71Sample Output#123456 #include <iostream>#include <iomanip>#include <string>using namespace std;void convert(int a){ ...原创 2012-11-22 23:52:28 · 97 阅读 · 0 评论 -
PAT1028 List Sorting
用vector最后一个用例超时了。。。 Sample Input 13 1000007 James 85000010 Amy 90000001 Zoe 60Sample Output 1000001 Zoe 60000007 James 85000010 Amy 90Sample Input 24 2000007 James ...原创 2012-11-22 23:53:05 · 106 阅读 · 0 评论 -
PAT1029 Median
用标准库的排序全部超时,需要自己实现,另外还不能用cin cout Sample Input4 11 12 13 145 9 10 15 16 17Sample Output13 #include <stdio.h>int N1[1000000];int N2[1000000];i...原创 2012-11-22 23:54:04 · 105 阅读 · 0 评论 -
PAT1031 Hello World for U
Sample Input:helloworld!Sample Output:h !e dl llowor #include <iostream>#include <iomanip>#include <string>using namespace std;...原创 2012-11-22 23:54:37 · 148 阅读 · 0 评论 -
PAT1035 Password
Sample Input 1:3Team000002 Rlsp0dfaTeam000003 perfectpwdTeam000001 R1spOdfaSample Output 1:2Team000002 RLsp%dfaTeam000001 R@spodfaSample Input 2:1team110 abcdefg332Sam...原创 2012-11-23 23:40:29 · 115 阅读 · 0 评论 -
PAT1036 Boys vs Girls
Sample Input 1:3Joe M Math990112 89Mike M CS991301 100Mary F EE990830 95Sample Output 1:Mary EE990830Joe Math9901126Sample Input 2:1Jean M AA980920 60Sample Output 2:...原创 2012-11-23 23:41:07 · 160 阅读 · 0 评论 -
PAT1040 Longest Symmetric String
求最长回文子串 #include <iostream>#include <string>#include <iomanip>using namespace std;int main(){ string a; getline(cin,a); int max = 0; int len...原创 2012-11-23 23:41:54 · 90 阅读 · 0 评论 -
PAT1042 Shuffling Machine
扑克洗牌 #include <iostream>#include <string>#include <vector>#include <iomanip>#include <map>#include <algorithm>using namespace std;void ...原创 2012-11-23 23:42:33 · 170 阅读 · 0 评论 -
PAT1041 Be Unique
找出只出现过一次的数,用各种排序必然超时,需要用数组做hash表Sample Input 1:7 5 31 5 88 67 88 17Sample Output 1:31Sample Input 2:5 888 666 666 888 888Sample Output 2:None #include <stdio.h>#include <stdlib.h&g...原创 2012-11-23 23:43:46 · 125 阅读 · 0 评论 -
PAT1003 Emergency
Sample Input5 6 0 21 2 1 5 30 1 10 2 20 3 11 2 12 4 13 4 1Sample Output2 4 #include <iostream>using namespace std;#define INF 1000000int Graph[500][50...原创 2012-11-29 23:46:47 · 134 阅读 · 0 评论 -
PAT1020 Tree Traversals
已知中序遍历 后序遍历,求层次遍历 Sample Input:72 3 1 5 7 6 41 2 3 4 5 6 7Sample Output:4 1 6 3 5 7 2 #include <string.h>#include <iostream>using namespace std;#define M...原创 2012-11-21 23:54:13 · 110 阅读 · 0 评论 -
PAT1019 General Palindromic Number
十进制转任意进制,并比较是否是回文数 Sample Input 1:27 2Sample Output 1:Yes1 1 0 1 1Sample Input 2:121 5Sample Output 2:No4 4 1 #include <string.h>#include <iostream&...原创 2012-11-21 23:53:47 · 103 阅读 · 0 评论 -
PAT1037 Magic Coupon
Sample Input:41 2 4 -147 6 -2 -3Sample Output:43 #include <iostream>#include <string.h>#include <vector>#include <algorithm>#include ...原创 2012-11-21 15:46:15 · 90 阅读 · 0 评论 -
PAT1002 A+B for Polynomials
多项式加法 Sample Input 2 1 2.4 0 3.2 2 2 1.5 1 0.5 Sample Output 3 2 1.5 1 2.9 0 3.2 #include <iostream>#include <iomanip>#include <vector>using namespace std;...原创 2012-11-18 23:56:20 · 85 阅读 · 0 评论 -
PAT1004 Counting Leaves
统计树的每一层上叶子节点的个数 Sample Input 2 1 01 1 02 Sample Output 0 1 #include <iostream>#include <iomanip>#include <string>#include <map>#include <vector>us...原创 2012-11-18 23:56:58 · 94 阅读 · 0 评论 -
PAT1005 Spell It Right
计算各个数字的和,并用英文将字母一个一个输出。 Sample Input: 12345 Sample Output: one five #include <iostream>#include <string>using namespace std;char* fun(int x){ switch(x) { ca...原创 2012-11-18 23:57:30 · 87 阅读 · 0 评论 -
PAT1006 Sign In and Sign Out
请根据记录找出当天开门和关门的人。 Sample Input:3CS301111 15:30:28 17:00:10SC3021234 08:00:00 11:25:25CS301133 21:45:00 21:58:40Sample Output:SC3021234 CS301133 #include <io...原创 2012-11-18 23:57:56 · 104 阅读 · 0 评论 -
PAT1007 Maximum Subsequence Sum
求最大连续子串和 Sample Input:10-10 1 2 3 4 -5 -23 3 7 -21Sample Output:10 1 4 #include <iostream>#include <vector>#include <string>using namespace ...原创 2012-11-18 23:58:22 · 83 阅读 · 0 评论 -
PAT1008 Elevator
电梯上升一层6秒,下降一层4秒,每层停留5秒Sample Input: 3 2 3 1 Sample Output: 41 #include <iostream>using namespace std;int main(){ int N; cin>>N; int current = 0...原创 2012-11-19 23:49:30 · 87 阅读 · 0 评论 -
PAT1009 Product of Polynomials
多项式乘法 Sample Input2 1 2.4 0 3.22 2 1.5 1 0.5Sample Output3 3 3.6 2 6.0 1 1.6 #include <string.h>#include <iostream>#include <iomanip>using namespa...原创 2012-11-19 23:50:03 · 88 阅读 · 0 评论 -
PAT1011 World Cup Betting
Sample Input1.1 2.5 1.71.2 3.0 1.64.1 1.2 1.1Sample OutputT T W 37.98 #include <iostream>#include <iomanip>#include <string>using namespace std;int ma...原创 2012-11-19 23:50:31 · 98 阅读 · 0 评论 -
PAT1012 The Best Rank
四门功课,输出排名最高的是哪个 Sample Input5 6310101 98 85 88310102 70 95 88310103 82 87 94310104 91 91 91310105 85 90 90310101310102310103310104310105999999Sample Output1 C1 M...原创 2012-11-19 23:50:55 · 99 阅读 · 0 评论 -
PAT1015 Reversible Primes
十进制转任意进制 假设十进制数为number,转换的进制为digits,则将numbers%digits(根据余数的情况做相应处理)结果保存在字符串str中,将numbers变为numbers/digits;直到numbers为零。得到的结果为逆序,需要将其倒转,倒转后即为所求。 这里不需要倒序,直接转 Sample Input:73 10...原创 2012-11-19 23:51:45 · 118 阅读 · 0 评论 -
PAT1024 Palindromic Number
Sample Input 1:67 3Sample Output 1:4842Sample Input 2:69 3Sample Output 2:13533 #include <iostream>#include <string>#include <iomanip>...原创 2012-11-20 23:51:23 · 100 阅读 · 0 评论 -
PAT1038 Recover the Smallest Number
由一道面试题改的 把数组排成最小的数 不同之处是这个是直接按字符串处理的 Sample Input:5 32 321 3214 0229 87Sample Output:22932132143287 #include <iostream>#include <string>#include <sstre...原创 2012-11-20 23:52:17 · 124 阅读 · 0 评论 -
PAT1013 Battle Over Cities
Sample Input3 2 31 21 31 2 3Sample Output100 #include <iostream>#include <string.h>using namespace std;int map[1000][1000]={0};int copy_map[1000][1000...原创 2012-11-29 23:59:51 · 119 阅读 · 0 评论