PAT (Advanced Level) Practice
PAT (Advanced Level) Practice
西阿西瓜瓜小花
暂无
展开
-
1063 Set Similarity
1063 Set Similarity解题代码测试结果问题整理解题代码#include<cstdio>#include<unordered_set>using namespace std;const int nmax = 50;int n, k, m, temp, a1, a2;unordered_set<int> s[nmax];int main() { scanf("%d", &n); for (int i = 0; i < n; i原创 2020-06-23 09:51:10 · 109 阅读 · 0 评论 -
1096 Consecutive Factors
1096 Consecutive Factors解题代码测试结果问题整理解题代码#include<cstdio>#include<cmath>#include<algorithm>using namespace std;typedef long long ll;ll n, cnt, left, m, temp, j;int main() { scanf("%lld", &n); ll sqr = (int)sqrt(1.0*n); for (原创 2020-06-22 21:55:45 · 129 阅读 · 0 评论 -
1024 Palindromic Number
1024 Palindromic Number解题代码测试结果问题整理解题代码#include<cstdio>#include<cstring>#include<algorithm>using namespace std;const int nmax = 1000;char str[nmax];int step, s;struct bign { int len; int p[nmax]; bign() { len = 0; memset(p原创 2020-06-22 15:16:20 · 98 阅读 · 0 评论 -
1023 Have Fun with Numbers
1023 Have Fun with Numbers解题代码测试结果问题整理解题代码#include<cstdio>#include<cstring>char str[20];int num[10];struct bign { int len; int p[21]; bign() { len = 0; memset(p, 0, sizeof(p)); }};bign change(char str[]) { bign a; a.len = strl原创 2020-06-22 14:37:40 · 103 阅读 · 0 评论 -
1047 Student List for Course
1047 Student List for Course解题代码测试结果问题整理解题代码#include<cstdio>#include<vector>#include<unordered_map>#include<algorithm>#include<cstring>using namespace std;unordered_map<int, vector<string> > m;int n, k, l,原创 2020-06-22 13:46:44 · 158 阅读 · 1 评论 -
1039 Course List for Student
1039 Course List for Student解题代码测试结果问题整理解题代码#include<cstdio>#include<vector>#include<unordered_map>#include<algorithm>using namespace std;int n, k, index, nstu;char str[5];unordered_map<string, vector<int> > m;原创 2020-06-22 10:46:17 · 82 阅读 · 0 评论 -
1078 Hashing
1078 Hashing解题代码测试结果问题整理解题代码#include<cstdio>#include<cmath>const int nmax = 20000;bool prime[nmax];bool isPrime(int x);int NextPrime(int x);int main() { int n, m, temp, j; scanf("%d%d", &n, &m); if (!isPrime(n)) n = NextPrime原创 2020-06-21 15:24:05 · 89 阅读 · 0 评论 -
1015 Reversible Primes
1013 数素数解题代码测试结果问题整理解题代码#include<cstdio>#include<cstring>#include<cmath>#include<algorithm>using namespace std;int Reser(int x,int d) { int temp[30]; int i = 0; while (x) { temp[i++] = x % d; x /= d; } reverse(temp,原创 2020-06-21 14:46:07 · 96 阅读 · 0 评论 -
1088 Rational Arithmetic
1088 Rational Arithmetic解题代码测试结果问题整理解题代码#include<cstdio>#include<algorithm>using namespace std;typedef long long ll;struct fraction { ll up, down;}a, b;typedef struct fraction fra;ll gcd(ll a, ll b) { return !b ? a : gcd(b, a%b);}f原创 2020-06-20 19:18:45 · 104 阅读 · 0 评论 -
1081 Rational Sum
1081 Rational Sum解题代码测试结果问题整理解题代码#include<cstdio>#include<cmath>typedef long long ll;struct fraction { ll up, down;}temp, sum;typedef struct fraction fra;ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b);}fra Reduction(fra a) { if原创 2020-06-20 16:18:54 · 124 阅读 · 0 评论 -
1104 Sum of Number Segments
1104 Sum of Number Segments解题代码测试结果问题整理解题代码#include<iostream>#include<cstdio>using namespace std;int main() { int n; cin >> n; double val, sum = 0.0; for (int i = 1; i <= n; i++) { cin >> val; sum += val * (n - i + 1原创 2020-06-18 16:03:41 · 185 阅读 · 0 评论 -
1069 The Black Hole of Numbers
1069 The Black Hole of Numbers解题代码测试结果问题整理解题代码#include<iostream>#include<cstdio>#include<algorithm>#include<string>using namespace std;bool cmp(char a, char b) { return a > b;}int main() { string a, b; cin >> a;原创 2020-06-18 15:41:18 · 111 阅读 · 0 评论 -
1049 Counting Ones
1049 Counting Ones解题代码测试结果问题整理解题代码#include<cstdio>int main() { int n, a = 1, ans = 0, left, now, right; scanf("%d", &n); while (n / a) { left = n / (a * 10); now = n / a % 10; right = n % a; if (now == 0) ans += left * a; else if原创 2020-06-18 10:53:23 · 92 阅读 · 0 评论 -
1008 Elevator
1008 Elevator解题代码测试结果问题整理解题代码#include<cstdio>int n, up, down, temp1, temp2;int main() { scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d", &temp2); if (temp2 > temp1) up += temp2 - temp1; else down += temp1 - temp2;原创 2020-06-18 10:01:51 · 104 阅读 · 0 评论 -
1085 Perfect Sequence
1085 Perfect Sequence解题代码测试结果问题整理解题代码#include<cstdio>#include<algorithm>using namespace std;const int nmax = 100010;int a[nmax], n, p, cnt;int main() { scanf("%d%d", &n, &p); for (int i = 0; i < n; i++) scanf("%d", &a[i]原创 2020-06-17 21:00:42 · 128 阅读 · 0 评论 -
1044 Shopping in Mars
1044 Shopping in Mars解题代码测试结果问题整理解题代码#include<cstdio>#include<algorithm>using namespace std;const int nmax = 100001;int a[nmax], s[nmax], n, m;int main() { scanf("%d%d", &n, &m); for (int i = 1; i <= n; i++) { scanf("%d",原创 2020-06-17 20:34:59 · 113 阅读 · 0 评论 -
1048 Find Coins
1048 Find Coins解题代码测试结果问题整理解题代码#include<cstdio>#include<algorithm>using namespace std;const int nmax = 100000;int a[nmax], n, m, i;bool Find(int index, int key) { int left = index + 1, right = n - 1, mid; while (left <= right) { m原创 2020-06-17 19:40:05 · 107 阅读 · 0 评论 -
1038 Recover the Smallest Number
1038 Recover the Smallest Number解题代码测试结果问题整理解题代码#include<cstdio>#include<string>#include<iostream>#include<algorithm>using namespace std;bool cmp(string a, string b) { return a + b < b + a;}int main() { int num; cin &原创 2020-06-16 17:42:05 · 110 阅读 · 0 评论 -
1070 Mooncake
1070 Mooncake解题代码测试结果问题整理解题代码#include<cstdio>#include<algorithm>using namespace std;struct stu { double num; double price;}s[1000];typedef struct stu st;bool cmp(st a, st b) { return a.price > b.price;}int main() { int N; doub原创 2020-06-16 15:51:02 · 122 阅读 · 0 评论 -
1048 Find Coins
1048 Find Coins解题代码测试结果问题整理解题代码#include<cstdio>#include<algorithm>#include<unordered_map>using namespace std;int judge[1001];int a[100000];int main() { int N, M, i; scanf("%d%d", &N, &M); for (int i = 0; i < N; i++)原创 2020-06-15 11:50:37 · 77 阅读 · 0 评论 -
1050 String Subtraction
1050 String Subtraction解题代码测试结果问题整理解题代码#include<cstdio>#include<iostream>#include<cstring>#include<unordered_map>using namespace std;int main() { char a[10001], b[10001]; cin.getline(a, 10001); cin.getline(b, 10001); unor原创 2020-06-15 10:10:17 · 98 阅读 · 0 评论 -
1092 To Buy or Not to Buy
1092 To Buy or Not to Buy解题代码测试结果问题整理解题代码#include<cstdio>#include<cstring>#include<iostream>#include<unordered_map>using namespace std;int main() { char a[1001], b[1001]; cin.getline(a, 1001); cin.getline(b, 1001); unorde原创 2020-06-15 10:02:34 · 76 阅读 · 0 评论 -
1084 Broken Keyboard
1084 Broken Keyboard解题代码测试结果问题整理解题代码#include<cstdio>#include<cstring>#include<iostream>#include<unordered_map>using namespace std;int main() { char a[81], b[81]; cin.getline(a, 81); cin.getline(b, 81); unordered_map<ch原创 2020-06-15 09:52:56 · 76 阅读 · 0 评论 -
1041 Be Unique
1041 Be Unique解题代码测试结果问题整理解题代码#include<cstdio>struct number { int cnt, index;}n[10001];using namespace std;int main() { int num, temp, min = 100001; scanf("%d", &num); for (int i = 0; i < num; i++) { scanf("%d", &temp); n[tem原创 2020-06-14 13:38:03 · 107 阅读 · 0 评论 -
1055 The World Richest
1055 The World's Richest解题代码测试结果问题整理解题代码#include<cstdio>#include<cstring>#include<algorithm>using namespace std;struct person { char name[9]; int age; int worth;}p[100000], p1[100000];typedef struct person per;struct que { in原创 2020-06-12 11:12:59 · 92 阅读 · 0 评论 -
1083 List Grades
1083 List Grades解题代码测试结果问题整理解题代码#include<cstdio>#include<algorithm>using namespace std;struct student { char name[11], id[11]; int score;}s[100000];typedef struct student stu;bool cmp(stu a, stu b) { return a.score > b.score;}in原创 2020-06-12 09:36:35 · 86 阅读 · 0 评论 -
1028 List Sorting
1028 List Sorting解题代码测试结果问题整理解题代码#include<cstdio>#include<cstring>#include<algorithm>using namespace std;int C;struct student { char id[7]; char name[9]; int score;}s[100000];typedef struct student stu;bool cmp(stu a, stu b)原创 2020-06-11 21:32:42 · 110 阅读 · 0 评论 -
1062 Talent and Virtue
1062 Talent and Virtue解题代码测试结果问题整理解题代码#include<cstdio>#include<algorithm>using namespace std;struct student { int id, virtue, talent, revel;}s[100000];typedef struct student stu;bool cmp(stu a, stu b) { if (a.revel != b.revel) return原创 2020-06-11 21:14:51 · 101 阅读 · 0 评论 -
1025 PAT Ranking
1025 PAT Ranking解题代码测试结果问题整理解题代码#include<cstdio>#include<cstring>#include<algorithm>using namespace std;struct student { char id[14]; int score; int position; int prank; int rank;}s[30000];typedef struct student stu;bool cmp原创 2020-06-11 20:48:42 · 78 阅读 · 0 评论 -
1012 The Best Rank
1012 The Best Rank解题代码测试结果问题整理解题代码#include<cstdio>#include<algorithm>#include<map>using namespace std;map<char, int> m;char refer[4] = { 'C','M','E','A' };int cnt;typedef struct scoreandrank { char course; int score, rank原创 2020-06-11 11:31:09 · 90 阅读 · 0 评论 -
1082 Read Number in Chinese
1082 Read Number in Chinese解题代码测试结果问题整理解题代码#include<cstdio>#include<cstring>char num[10][5] = { "ling","yi","er","san","si","wu","liu","qi","ba","jiu" };char wei[5][5] = { "Shi","Bai","Qian","Wan","Yi" };int main(){ char str[11]; scanf原创 2020-06-10 21:22:04 · 73 阅读 · 0 评论 -
1077 Kuchiguse
1077 Kuchiguse解题代码测试结果问题整理解题代码 #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> using namespace std; int main() { int num, len, min = 257, i, j; scanf("%d\n", &num); char word[100][257], re原创 2020-06-10 13:45:17 · 111 阅读 · 0 评论 -
1035 Password
1035 Password解题代码测试结果问题整理解题代码#include<cstdio>#include<cstring>struct password { char name[11]; char word[11]; bool flag;}p[1000];int main(){ int num, cnt = 0; scanf("%d", &num); for (int i = 0; i < num; i++) { p[i].flag =原创 2020-06-10 11:35:56 · 107 阅读 · 0 评论 -
1005 Spell It Right
1005 Spell It Right解题代码测试结果问题整理解题代码#include<cstdio>#include<cstring>int main(){ char stan[10][6] = { "zero","one","two","three","four","five","six","seven","eight","nine" }; char num[100]; scanf("%s", num); int sum = 0; int len = strl原创 2020-06-10 10:50:26 · 72 阅读 · 0 评论 -
1073 Scientific Notation
1073 Scientific Notation解题代码测试结果问题整理解题代码#include<cstdio>#include<cstring>int main(){ char str[10000]; scanf("%s", str); if (str[0] == '-') printf("-"); int len = strlen(str); int pol = 0; while (str[pol] != 'E') { pol++; }; int num原创 2020-06-10 10:35:06 · 85 阅读 · 0 评论 -
1061 Dating
1061 Dating解题代码测试结果问题整理解题代码#include<cstdio>#include<cstring>#include<algorithm>using namespace std;int main(){ char date[7][4] = { "MON","TUE","WED","THU","FRI","SAT","SUN" }; char str1[61], str2[61], str3[61], str4[61]; scanf("原创 2020-06-10 10:12:55 · 77 阅读 · 0 评论 -
1001 A+B Format
1001 A+B Format解题代码测试结果问题整理解题代码#include<cstdio>#include<cstring>int main(){ int a, b, ans; scanf("%d %d", &a, &b); ans = a + b; if (ans < 0) { printf("-"); ans = -ans; } char ret[8]; sprintf(ret, "%d", ans); int len原创 2020-06-09 18:03:06 · 91 阅读 · 0 评论 -
1058 A+B in Hogwarts
1027 Colors in Mars解题代码测试结果问题整理解题代码#include<cstdio>int main(){ long long a1, b1, c1, a2, b2, c2; scanf("%lld.%lld.%lld %lld.%lld.%lld", &a1, &b1, &c1, &a2, &b2, &c2); c1 += (a1 * 17 + b1) * 29; c2 += (a2 * 17 + b2) * 2原创 2020-06-08 15:38:03 · 90 阅读 · 0 评论 -
1027 Colors in Mars
1027 Colors in Mars解题代码测试结果问题整理解题代码#include<cstdio>int main(){ int a, b, c; scanf("%d %d %d", &a, &b, &c); char d[13] = { '0','1','2','3','4','5','6','7','8','9','A','B','C'}; printf("#%c%c%c%c%c%c", d[a / 13 % 13], d[a % 13], d[b原创 2020-06-08 15:09:27 · 82 阅读 · 0 评论 -
1019 General Palindromic Number
1019 General Palindromic Number解题代码测试结果问题整理解题代码#include<cstdio>int main(){ int num, base, i = 0, j; int a[31]; scanf("%d%d", &num, &base); do { a[i++] = num % base; num /= base; } while (num != 0); for (j = 0; j < i / 2; j++)原创 2020-06-08 13:25:07 · 63 阅读 · 0 评论