- 博客(44)
- 资源 (5)
- 收藏
- 关注
原创 A1020 Tree Traversals (25 分)
#include <bits/stdc++.h>using namespace std;struct node{ int date; node* lchild; node* rchild;};int post[30];int in[30];int n;node* create(int postL, int postR, int inL, int inR){ if(postL >postR){ return NULL; } node* root = new
2021-03-13 10:45:04 88
原创 A1060 Are They Equal (25 分)
写了个简单的代码,得分17/25 。满分代码: 需要考虑好多的东西#include <iostream>#include <vector>#include <algorithm>#include <string.h>using namespace std; int n; //有效位数string deal(string s, int& e){ int k = 0; //去掉s的前导0 while(s.length() >
2021-03-10 17:21:40 152
原创 A1015 Reversible Primes (20 分)
#include <bits/stdc++.h>using namespace std;bool isPrime(int n){ if(n <= 1){ return false; } int sqr = (int)sqrt(1.0*n); for(int i = 2; i <= sqr; i++){ if(n % i == 0){ return false; } } return true;} int num[111];int main
2021-03-09 19:33:30 73
原创 A1081 Rational Sum (20 分)
#include <bits/stdc++.h>using namespace std; typedef long long ll;struct Fenshu{ ll up; ll down;}fenshu[110];ll up, down;ll gcd(ll a, ll b){ if(b == 0) return a; else return gcd(b, a%b);}void huajian(ll a, ll b){ ll common = gcd(a,
2021-03-09 19:32:09 79
原创 A1069 The Black Hole of Numbers (14/20 分)
#include <iostream>#include <algorithm>#include <sstream>using namespace std; bool cmp(char c1, char c2){ return c1 > c2;}//string -> intint change(string s){ int n; stringstream ss; ss << s; ss >> n; retu
2021-03-09 19:30:59 134
原创 C++标准模板库(STL介绍)--string
1.+=string str1 = "ab", str2 = "xy";string str = str1 + str2;2.compare operator==, !=, <, <=, >, >= 比较规则是字典序3.length()/size()4.insert()方法一:string str = "abcxyz", str2 = "opq";str.insert(3, str2);输出:abcopqxyz;方法二:string str =
2021-03-09 16:34:40 136 1
原创 A1047 Student List for Course (25 分)
#include <iostream>#include <vector>#include <algorithm>#include <string.h>using namespace std; const int M = 2510;vector<int> course[M];char name[40010][5];bool cmp(int a, int b){ return strcmp(name[a], name[b]) &l
2021-03-09 15:46:31 119
原创 A1039 Course List for Student (25 分)
思路:1. 学生的姓名利用字符串hash求解,由于题中所给的是 **三位大写数字+一位字母** ,所以可利用散列知识,开辟数组的大小为:26 * 26 * 26 * 10。 2. 建立vector二维数组,存放每个同学的选课情况。 `vector<int> vi[100]`#include <iostream>#include <vector>#include <algorithm>using namespace std; const int
2021-03-09 15:19:18 127
原创 C++标准模板库(STL介绍)--vector
vector1.push_back()在vector后面添加一个元素x#include <iostream>#include <vector>using namespace std; /* run this program using the console pauser or add your own getch, system("pause") or input loop */int main(int argc, char** argv) { vector&
2021-03-09 11:27:28 137 1
原创 大整数相加
大整数的存储,一般先用字符串读入,然后再把字符串另存至bign结构体中。结构体定义:struct bign{ int d[1000]; int lne; bign(){ memset(d, 0, sizeof(d)); len = 0; }}
2021-03-08 20:55:37 99
原创 A1059 Prime Factors (25 分)
#include <iostream>#include <math.h>using namespace std;struct factor{ int x, cnt; //x为质因子,cnt为该质因子的个数 }fac[10];bool isPrime(int num){ if(num <=1 ){ return false; } int n = (int)sqrt(num*1.0); for(int i = 1; i < n; i++)
2021-03-08 20:09:51 65
原创 A1096 Consecutive Factors (20 分)
#include <iostream>#include <math.h>using namespace std;typedef long long ll;int main(int argc, char** argv) { ll n; cin >> n; ll sqr = (ll)sqrt(1.0*n), ansI = 0, ansLen = 0; for(ll i = 2; i <= sqr; i++){ ll temp = 1,
2021-03-08 20:07:35 79
原创 A1049 Counting Ones (30 分)
暴力求解 【22/30分】新知识: 求解某一个字符串中有几个字符‘1’时用的函数。count(str.begin(), str.end(), '1');代码#include <bits/stdc++.h>using namespace std;/* run this program using the console pauser or add your own getch, system("pause") or input loop */string change(long
2021-03-08 20:06:48 133 2
原创 A1010 Radix (25 分)【22/25】
#include <bits/stdc++.h>using namespace std;/* run this program using the console pauser or add your own getch, system("pause") or input loop */long long int getNum(string str, long long radix){ long long sum = 0; for(int i = 0; i < str.leng
2021-03-08 20:05:59 129
原创 A1104 Sum of Number Segments (20 分)
这种题……写出来就找到规律了但是还有个坑,这个题用double类型有一个测试点不能通过,得用 long double 类型,且输入输出用 scanf("%Lf", num); Lf#include <cstdio>/* run this program using the console pauser or add your own getch, system("pause") or input loop */int main(int argc, char** argv) {
2021-03-08 20:05:25 129
原创 A1101 Quick Sort (25 分)
暴力求解 【14/25分】#include <bits/stdc++.h>using namespace std;/* run this program using the console pauser or add your own getch, system("pause") or input loop */const int maxn = 100010;int main(int argc, char** argv) { int n, num[maxn] = {0},.
2021-03-05 17:18:36 125
原创 逐步递推 A1093 Count PAT‘s (25 分)
暴力会超时。思路: 每个字母A左边的P的个数 * 该字母A右边的T的个数 ,然后结果相加即可。#include <bits/stdc++.h>using namespace std;const int maxn = 100010;const int mod = 1000000007;int main(int argc, char** argv) { int leftP[maxn] = {0}, rightT = 0; string str; cin >>
2021-03-05 17:18:05 140
原创 A1048 Find Coins (25 分)
#include <bits/stdc++.h>using namespace std;/* run this program using the console pauser or add your own getch, system("pause") or input loop */const int maxn = 100010;int main(int argc, char** argv) { int n, M, a[maxn]; cin >> n &g
2021-03-05 17:17:33 160
原创 A1085 Perfect Sequence (25 分)
#include <bits/stdc++.h>using namespace std;/* run this program using the console pauser or add your own getch, system("pause") or input loop */const int maxn = 100010;int main(int argc, char** argv) { int n, arr[maxn]; long long int p;
2021-03-05 17:17:01 79
原创 A1085 Perfect Sequence (25 分)
#include <bits/stdc++.h>using namespace std;const int maxn = 100010;int n, p, a[maxn];//在[left, n-1]之间找第一个大于x的数 int binarySearch(int left, long long x){ if(a[n-1] <= x) return n; int l = left, r = n-1, mid; while(l < r){ mid = (l +
2021-03-05 17:16:29 65
原创 A1067 Sort with Swap(0, i) (18/25 分)
#include <bits/stdc++.h>using namespace std;/* run this program using the console pauser or add your own getch, system("pause") or input loop */int main(int argc, char** argv) { int n; cin >> n; int pos[100010]; int left = 0; //记录不在
2021-03-05 17:15:58 60
原创 A1037 Magic Coupon (25 分)
我的方法#include <bits/stdc++.h>using namespace std;/* run this program using the console pauser or add your own getch, system("pause") or input loop */const int maxn = 100010;bool cmp(int m, int n){ return m > n ;}int main(int argc, char**
2021-03-05 17:15:28 97
原创 1033 To Fill or Not to Fill (25 分)【不会
#include <bits/stdc++.h>using namespace std;/* run this program using the console pauser or add your own getch, system("pause") or input loop */const int maxn = 510;const int INF = 1000000000;struct Station{ double price; double dis;}sta[ma
2021-03-05 17:14:39 61
原创 A1070/B1020 Mooncake (25 分)【避坑!
题目给的输入条件为如下,尤其注意用黑体字表明的地方。Each input file contains one test case. For each case, the first line contains 2 positive integers N (≤1000), the number of different kinds of mooncakes, and D (≤500 thousand tons), the maximum total demand of the market. Then th
2021-03-05 17:13:27 167
原创 B1023 组个最小数 (20 分)
#include <bits/stdc++.h>using namespace std;/* run this program using the console pauser or add your own getch, system("pause") or input loop */int main(int argc, char** argv) { int n; int numCount[10]; string str; for(int i = 0; i <
2021-03-05 17:13:00 59
原创 A1041 Be Unique (20 分)
#include <iostream>#include <bits/stdc++.h>using namespace std; /* run this program using the console pauser or add your own getch, system("pause") or input loop */int main(int argc, char** argv) { int num[100010] = {0}; int numAll[100
2021-03-02 12:32:12 72
原创 A1092_B1039 To Buy or Not to Buy (20 分)
这部分的重点是:将【A-Z,a-z,0-9】转换为ASCII值,可以进行巧妙的减法使其的范围在100以内。char change(char c){ if(c >= '0' && c <= '9') return c - '0'; // 0-9 else if(c >= 'A' && c <= 'Z') return c - 'A' + 10; //10-35 else if(c >= 'a' && c <= '
2021-03-02 12:31:37 106
原创 B1033旧键盘打字 (20 分)
#include <iostream>#include <bits/stdc++.h>using namespace std;/* run this program using the console pauser or add your own getch, system("pause") or input loop */int main(int argc, char** argv) { string str1, str2;// cin >> str1
2021-03-02 12:30:54 114
原创 A1084_B1029 旧键盘 (20 分)
#include <iostream>#include <bits/stdc++.h> using namespace std;/* run this program using the console pauser or add your own getch, system("pause") or input loop */int main(int argc, char** argv) { //cout << (97 - '0'); // printf
2021-03-02 12:30:03 66
原创 A1055 The World‘s Richest (25 分)
**整体思路:**先按照整体排序,然后通过年龄范围输出适当的。注意: 必须进行预处理!!注意到M的范围为100,将每个年龄中前100以内的存入到另一个数组中(因为某个年龄一百名以外的肯定不会被遍历到),后面的查询操作则直接在这个数组中进行。这个预处理会明显降低查询的复杂度。如果不进行处理则会超时。#include <iostream>#include <bits/stdc++.h>using namespace std;/* run this program usin
2021-03-02 12:29:32 156
原创 A1028 List Sorting (25 分)
#include <bits/stdc++.h>using namespace std;/* run this program using the console pauser or add your own getch, system("pause") or input loop */struct Student{ char id[10]; char name[10]; int score;}stu[100010];int c = 0;bool cmp(Student
2021-03-02 12:29:02 70
原创 A1025 PAT Ranking (25 分)
#include <iostream>#include <string.h>#include <algorithm>using namespace std; /* run this program using the console pauser or add your own getch, system("pause") or input loop */struct Student{ char id[15]; int score; int group
2021-03-02 12:28:28 70
原创 A1012 The Best Rank (25 分)
需要注意的点:成绩排名为并列时的代码。#include <iostream>#include <algorithm>using namespace std;/* run this program using the console pauser or add your own getch, system("pause") or input loop */struct Student{ int id; int grade[4]; //存放四个分数 }stu[2010]
2021-03-02 12:27:57 79
原创 A1062 Talent and Virtue (25 分)
16分代码#include <iostream>#include <algorithm> using namespace std;/* run this program using the console pauser or add your own getch, system("pause") or input loop */const int MAX = 100010;struct user{ string id; int vir; int ten;}.
2021-03-02 12:27:27 137
原创 C++的数组下标可以是字符!!!
C++的数组下标可以是字符,存储的是ASCII码的值/解释如下:C++中字符在bai计算机内存du储的是字zhi符的ASCII码;而ASCII码实质是数字,例dao如‘a’是97,‘A’是65;如果用字符作为下标,实质就是用该字符的ASCII码作为下标;但是在用字符作为下标时没有数字直观,容易引起数组越界,因此不建议这样用。适用情况,统计每个字符出现的次数的数组。...
2021-03-01 21:09:45 1969
原创 A1077 Kuchiguse (20 分)
#include <iostream>#include <string.h>#include <algorithm>using namespace std; /* run this program using the console pauser or add your own getch, system("pause") or input loop */int minLen = 256;int main(int argc, char** argv) {
2021-03-01 17:38:52 57
原创 B1048 数字加密 (20 分) 【避免入坑
看起来挺普通的一道题为什么通过率不高呢? 刚开始一直是16分(满分20),百度了一番……如果A 和 B的长度相等,按照题意处理即可。如果A的长度小于B的长度,按照样例我们可以在A的前面补上适当的零。这背后的逻辑是,如果A相应的位上是零,加密操作不会改变B对应位上的数字。 那么,疑问来了,如果A的长度大于B呢? 答案竟然是在B的前面也补上足够的零。按我刚开始的思路,直接将较长的那个数组剩余的数字直接输出,不给补0,在A的长度大于B的长度时,B-A的时候就会出现错误奥~~~~ 也是扣分点然后这个题还有个小
2021-03-01 17:38:11 150
原创 A1073_B1024 Scientific Notation (20 分)
#include <iostream>#include <string.h>using namespace std;/* run this program using the console pauser or add your own getch, system("pause") or input loop */int main(int argc, char** argv) { char str[10010]; cin.getline(str, 10010);
2021-03-01 17:37:36 67
原创 A1061_B1014 福尔摩斯的约会 【18/20分】
#include <iostream>#include <string.h>using namespace std;/* run this program using the console pauser or add your own getch, system("pause") or input loop */int main(int argc, char** argv) { char str[4][60]; char week[7][5] = { "MON",
2021-03-01 17:36:57 131
原创 B1009 说反话 (20 分)
#include <iostream>#include <string.h>using namespace std;/* run this program using the console pauser or add your own getch, system("pause") or input loop */int main(int argc, char** argv) { char str[90]; cin.getline(str, 90); int len
2021-03-01 17:36:23 45
全网最全安卓复习资料PPT+复习题
2020-11-24
中北大学安卓实验2-8
2020-11-24
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人