- 博客(69)
- 收藏
- 关注
原创 1046 Shortest Distance (20)(20 分)
#include<iostream>#include<algorithm>using namespace std;const int maxn = 1e5 + 10;int a[maxn], n;int main(){ scanf("%d", &n); int x, tot = 0; for (int i = 1; i <= n; i++)...
2018-08-22 12:01:28
220
原创 1042 Shuffling Machine (20)(20 分)
#include<iostream>#include<string>#include<cstring>using namespace std;const int maxn = 1e3 + 10;int num[maxn], temp[maxn],shuff[maxn], k;void show(int n){ if (n <= 13)pr...
2018-08-22 11:49:38
252
原创 1018 锤子剪刀布(20 分)
#include<iostream>#include<algorithm>#include<map>using namespace std;char num[3] = { 'B','C','J' };int a[3], b[3];int n;int as, ap, af, bs, bp, bf;void show(int a[]){ int...
2018-08-22 11:39:21
704
原创 1012 数字分类 (20)(20 分)
#include<iostream>#include<algorithm>#include<vector>using namespace std;int n, x;vector<int>a[6];int main(){ scanf("%d", &n); while (n--) { scanf("%d", &a
2018-08-22 11:21:41
400
原创 1008 数组元素循环右移问题 (20)(20 分)
#include<iostream>#include<algorithm>using namespace std;const int maxn = 1e4 + 10;int n, m;int a[maxn];int main(){ scanf("%d%d", &n, &m); for (int i = 0; i < n; i++)s...
2018-08-22 11:11:37
347
原创 1046 划拳(15 分)
#include<iostream>#include<algorithm>using namespace std;int n;int main(){ scanf("%d", &n); int acount = 0, bcount = 0; while (n--) { int a, ax, b, bx; scanf("%d%d%d%d", ...
2018-08-22 11:04:37
407
原创 1026 程序运行时间(15 分)
#include<iostream>#include<cmath>#include<algorithm>using namespace std;const int CLK_TCK = 100;int c1, c2;int main(){ scanf("%d%d", &c1, &c2); int t = round((c2 - ...
2018-08-22 10:58:54
531
原创 1016 部分A+B(15 分)
#include<iostream>#include<string>#include<cstring>using namespace std;string a, b;int da, db;typedef long long LL;LL getnum(string s, int d){ int ans = 0; for (int i = 0;...
2018-08-22 10:53:50
272
原创 1011 A+B和C (15)(15 分)
#include<iostream>typedef long long LL;LL a, b, c;int t;int main(){ scanf("%d", &t); for(int i=1;i<=t;i++) { printf("Case #%d: ", i); scanf("%lld%lld%lld", &a, &b, &
2018-08-22 10:49:10
262
原创 1001 害死人不偿命的(3n+1)猜想 (15)(15 分)
#include<iostream>using namespace std;int main(){ int n, ans = 0; cin >> n; while (n != 1) { if (n % 2 == 0)n /= 2; else n = (3 * n + 1) / 2; ans++; } cout << ans; r...
2018-08-22 10:42:50
716
原创 Tensorflow、keras、pytorch、cuda(GPU加速)在Windows10下的配置
之前这些装过好多次,踩了挺多坑的,这次帮同学装,顺手记录一下配置过程目录anaconda安装安装更换源TensorFlow(GPU)GPUCPU(不建议安装CPU版)cuda配置GPU加速cudacudnn建议大家安装anaconda,有挺多同学自己在linux里面自己下载需要的模块,这样也可以,但是不如直接anaconda比较方便,里面有好多库都包含进...
2018-08-06 13:07:09
1683
原创 1079 Total Sales of Supply Chain (25)(25 分)
DFS:递归终点为叶子结点,此时计算乘积#include<iostream>#include<queue>#include<vector>using namespace std;const int maxn = 1e5 + 10;struct node { double p, product; vector<int>child;...
2018-08-06 12:34:29
470
原创 1102 Invert a Binary Tree(25 分)
静态树存储,找一下根节点,遍历的时候左右节点换一下就可以了算法笔记上给的方法是:后序遍历时交换左右子树,重建二叉树,再进行遍历#include<iostream>#include<cstring>#include<queue>#include<vector>using namespace std;int n;const int ...
2018-08-06 10:38:10
866
原创 二叉树、BST、并查集、堆、哈夫曼树
二叉树操作,二叉搜索树操作,先序层序等遍历,树的旋转,并查集,最大堆建立,插入,删除,堆排序、哈弗曼树WPL(带权路径和最大)程序来源于“算法笔记”,复习的时候手写了一遍,基础还是很有用的,这些常用的记一记感觉确实做题的时候顺畅一些#include<iostream>#include<vector>#include<queue>using na...
2018-08-04 23:15:13
319
原创 1043 Is It a Binary Search Tree (25)(25 分)
模板题目:树的创建(插入节点,新建节点),树的遍历(前中后遍历都是DFS)#include<iostream>#include<vector>using namespace std;struct node { int data; node* lchild; node* rchild;};int num[10000], n;node* Newnode(...
2018-08-03 16:10:08
709
原创 1053 Path of Equal Weight (30)(30 分)
典型题目:静态树存储,DFS遍历#include<iostream>#include<vector>#include<algorithm>using namespace std;int n, m, s;const int maxn = 110;struct node { int weight; vector<int>child;...
2018-08-03 14:01:00
570
原创 1074 Reversing Linked List (25)(25 分)
#include<iostream>#include<algorithm>#include<vector>using namespace std;const int maxn = 1e5 + 10;struct Node { int add, data, next;}node[maxn];void init(){ for (int i =...
2018-07-25 22:46:28
910
1
原创 1022 Digital Library (30)(30 分)
要气疯了,,,最后发现是没写%07d,emmmm#include<iostream>#include<string>#include<algorithm>#include<vector>using namespace std;const int maxn = 1e4 + 10, maxnm = 1e3 + 10;struct boo...
2018-07-19 15:52:46
393
1
原创 1080 Graduate Admission (30)(30 分)
emmm好久没来写过了,写了一个思路比较清晰的解法,仅供参考#include<iostream>#include<algorithm>#include<vector>using namespace std;const int maxn = 4e4 + 10;const int maxm = 110;const int maxk = 5;struct...
2018-06-19 23:41:15
374
原创 Opencv3.4.1与VS2015安装
https://jingyan.baidu.com/article/dca1fa6f13bd55f1a44052b9.html教程按照这个来的,有的地方需要改动,不然会报错第五步:Debug与Release中678步都要添加一遍第八步:OpenCV3.4.1添加依赖项应该是opencv_world341.lib...
2018-05-13 19:18:30
3004
原创 1099. Build A Binary Search Tree (30)
这个写的有点麻烦了,最后对应用的map其实中序遍历的时候边遍历边写入会简洁很多#include#include#include#include#includeusing namespace std;const int maxn = 1e3 + 10;int tree[maxn][2], n, s[maxn];vectorinorder, levelorder;mapm;
2018-03-26 22:50:24
140
原创 1097. Deduplication on a Linked List (25)
好久没来更新了,之前买了晴神宝典,推荐给大家,专门针对PAT的书,非常管用,最近感觉进步还可以,思路清晰多了好了,然后这条题目,比较简单吧,静态链表,然后分割,我用了两个vector存的两个分割后的链表,map用来做已出现的数字的标记(记得取相反的),最后输出一下就好#include#include#includeusing namespace std;const int maxn
2018-03-22 19:53:26
184
原创 1084. Broken Keyboard (20)
two points应用#include#include#include#includeusing namespace std;string a, b;vectorss;int main(){ getline(cin, a); getline(cin, b); for (int i = 0; i = 'a'&&a[i] <= 'z')a[i] -= 32; for (i
2018-03-12 20:42:55
127
原创 1095. Cars on Campus (30)
#include#include#include#includeusing namespace std;const int maxn = 1e4 + 10;int n, k;struct car { char num[10]; int hh, mm, ss; int flag; int intime, outtime; void read() { scanf("%s %d:
2018-03-12 20:08:05
133
原创 1080. Graduate Admission (30)
二次更新正确答案#include<iostream>#include<algorithm>#include<vector>using namespace std;const int maxn = 1e5 + 10;struct point { int id, ge, gi, fg; int choice[5]; bool operator<...
2018-03-05 18:33:42
197
原创 1079. Total Sales of Supply Chain (25)
bfs遍历一下就行double读入用lf才能读入,否则会出错#include<iostream>#include<algorithm>#include<vector>#include<queue>using namespace std;const int maxn = 1e5 + 10;vector<int>a[maxn];...
2018-03-05 15:51:25
135
原创 1074. Reversing Linked List (25)
这个题目很经典,有两个点,一个是地址给出来怎么连接到一起,另一个是每k个数翻转#include<iostream>#include<algorithm>using namespace std;const int maxn = 1e5 + 10;int w[maxn], nt[maxn],f[maxn];int s, n, k, x, cnt;int main()...
2018-03-02 11:27:07
211
原创 1045. Favorite Color Stripe (30)(LISDP)
给Eva想要的颜色编序号,之后就转换为求最长非递减上升子序列长度#include<iostream>#include<algorithm>using namespace std;int n, m, l, num;const int maxn = 1e4 + 10;int a[maxn], b[maxn], dp[maxn], x;int main(){ in...
2018-02-28 20:29:26
292
原创 1066. Root of AVL Tree (25)
好久没写博客了,更新一波这个是课本上的东西,一模一样,就是树的形式变换要记一下,没那个示意图估计是写不出来了还有就是之前碰到二叉树建树的问题发现课本没有建二叉树的程序,其实就是这个题目,二叉树怎么都可以建出来,只是不一定是avl树(最坏是一条链)#include#includeusing namespace std;const int maxn = 21;int n, a[ma
2018-02-27 17:37:46
241
原创 1030. Travel Plan (30)
#include#includeconst int INF = 1e6;using namespace std;const int maxn = 5e2 + 10;int md[maxn][maxn], mc[maxn][maxn];int vis[maxn], dis[maxn], path[maxn], c[maxn];int n, m, s, d, c1, c2, dist,
2018-01-29 21:44:46
285
原创 1029. Median (25)
#include#include#includeusing namespace std;vectora;int n, m;long int x;int main(){ cin >> n; while (n--)cin >> x, a.push_back(x); cin >> m; while (m--)cin >> x, a.push_back(x); nth_eleme
2018-01-29 17:13:23
108
原创 1025. PAT Ranking (25)
#include#include#include#includeusing namespace std;const int maxn = 110;const int maxk = 310;int n, k;struct point { string rn; int score; int local_number; int local_rank; int final_ran
2018-01-28 16:02:32
106
转载 1016. Phone Bills (25)
#include#include#include#include#define daytime 24using namespace std;struct PhoneBills { char id[21]; bool on; int month; int dd, hh, mm;};void reaDln(PhoneBills * PB, int N)//这个真的厉害,oNof
2018-01-07 21:36:14
131
原创 1015. Reversible Primes (20)
#include#include#includeusing namespace std;bool isPrime(int N){ if (N < 2)return false; if (N == 2 || N == 3)return true; for (int i =sqrt(N); i >=2; i--) if (N%i == 0)return false; return
2018-01-06 23:05:33
133
原创 1014. Waiting in Line (30)
果然最重要的还是读懂题目,,这个是动态的排队过程,黄线外面的人看那个队少了一个人就插进去,一开始想简单了,以为是大家都全部排好再开始,这个题目是黄线以内的排好后就开始,后面的人动态的插进去#includeusing namespace std;const int MaxN = 10001;int N, M, K, Q;int protime[MaxN]; typedef stru
2018-01-06 21:28:15
158
转载 1013. Battle Over Cities (25)
#include#includeusing namespace std;const int MaxE = 1001;int edge[MaxE][MaxE];int visited[MaxE];int N, M, K;void dfs(int i){ visited[i] = 1; for (int j = 1; j <= N; j++) { if (!visited[j
2018-01-06 18:12:28
110
原创 1012. The Best Rank (25)
#include#include#include#includeusing namespace std;struct stu { int ID; int C; int M; int E; int A; int bestRank; char bestItem; stu(int id, int c, int m, int e) :ID(id), C(c), M(m), E(e
2018-01-06 15:26:57
169
原创 1011. World Cup Betting (20)
#includeusing namespace std;#includeint findmax(double team[]){ double max=0.0; int num; for (int i = 0; i < 3; i++) { if (team[i] > max) { max = team[i]; num = i; } } return num
2018-01-05 09:27:47
120
原创 1010. Radix (25)
#include#includeusing namespace std;long long Cal(char a){ if (a >= '0'&&a <= '9') return a - '0'; else return a - 'a' + 10;}long long NUM(char N[], long long radix){ long long sum = 0;
2018-01-05 08:34:53
177
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人