- 博客(86)
- 收藏
- 关注
原创 PTA5-2 畅通工程之最低成本建设问题 (克鲁斯卡尔)
某地区经过对城镇交通状况的调查,得到现有城镇间快速道路的统计数据,并提出“畅通工程”的目标:使整个地区任何两个城镇间都可以实现快速交通(但不一定有直接的快速道路相连,只要互相间接通过快速路可达即可)。现得到城镇道路统计表,表中列出了有可能建设成快速路的若干条道路的成本,求畅通工程需要的最低成本。输入格式:输入的第一行给出城镇数目NN (1< N \le 10001N≤1000)
2016-08-20 09:12:34
1967
原创 PTA5-1 任务调度的合理性
假定一个工程项目由一组子任务构成,子任务之间有的可以并行执行,有的必须在完成了其它一些子任务后才能执行。“任务调度”包括一组子任务、以及每个子任务可以执行所依赖的子任务集。比如完成一个专业的所有课程学习和毕业设计可以看成一个本科生要完成的一项工程,各门课程可以看成是子任务。有些课程可以同时开设,比如英语和C程序设计,它们没有必须先修哪门的约束;有些课程则不可以同时开设,因为它们有先后的依赖
2016-08-20 08:46:29
743
原创 POJ3278Catch That Cow
让我re了好几发的题,后来跟着标称一行一行的对比,发现我的判断顺序有问题。要先判断是否越界,再判断标记变量,否则会指针越界。#include#include#include#include#include#include#includeusing namespace std;const int N = 200100;int n,k;struct state{ i
2016-08-18 14:14:42
343
原创 POJ2993Emag eht htiw Em Pleh
终于撸完了最后一道模拟题,恶心死我了。。。#include#include#include#include#include#include#includeusing namespace std;char Map[40][40];void IntMap(){ for(int i=0;i<17;i++) { for(int j=0;j<33;j++) { i
2016-08-17 20:47:40
335
原创 POJ2996Help Me with the Game
简单的模拟题,1a#include#include#include#include#include#include#includeusing namespace std;char Map[40][40];int t;void readMap(){ for(int i=0;i<17;i++) scanf("%s",Map[i]);}char tracol(int
2016-08-17 15:43:13
472
原创 POJRobot Motion
1a,开心,模拟题#include#include#include#include#include#include#includeusing namespace std;int n,m,k;int Map[15][15];int road[15][15];int swh[4][2]={-1,0,0,1,1,0,0,-1};void Intmap(){ char ch
2016-08-16 21:35:36
478
原创 POJ2632Crashing Robots
1a,开心模拟题,恶心的很。。。。#include#include#include#include#include#include#includeusing namespace std;int T,A,B,N,M;bool flag;struct Map{ int id,dir;}a[120][120],t;int swhdir[4][2]={-1,0,0,1,
2016-08-16 17:01:53
254
原创 POJ1068Parencodings
括号匹配,看懂题意就可以做出来。1a还是蛮开心的#include#include#include#include#include#include#includeusing namespace std;int n;bool p[50];//'(':false ')':truevoid readp(){ memset(p,false,sizeof(p)); int i,P
2016-08-15 22:55:08
292
原创 HDUOJ5832A water problem&&2016中国大学生程序设计竞赛 - 网络选拔赛1001
竟然只是用数组模拟大数然后做取模运算,自己还是太菜,做题太少。#include#include#include#include#include#includeusing namespace std;char a[10000050];int main(){ int j=1; while(~scanf("%s",a)) { int len=strlen(a),mod=
2016-08-15 15:21:12
513
原创 HDUOJ5835Danganronpa&&2016中国大学生程序设计竞赛 - 网络选拔赛1004
这题更水,为啥我么就没发现这个问题呢。#include#include#include#include#include#includeusing namespace std;int main(){ int T; scanf("%d",&T); for(int i=0;i<T;i++) { int n,s=0; scanf("%d",&n); while(n-
2016-08-15 15:09:28
396
原创 HDUOJ5832Lweb and String&&2016中国大学生程序设计竞赛 - 网络选拔赛1011
真是水题,当时没读懂题意,还以为是最长上升子序列,结果竟是是统计不重复出现的数字。。。。。。#include#include#include#include#include#includeusing namespace std;int main(){ int T,j=1; scanf("%d",&T); while(T--) { int h[200]; mems
2016-08-15 15:04:15
469
原创 POJ3295Tautology
一道非常恶心的模拟题。。。。暴力枚举出所有情况,后缀式求值,如果求出假,就不是重言式。#include#include#include#include#include#includeusing namespace std;int a[30][7],p,q,r,s,t;char WWF[110];stackS;void mklist(){ int j=0; for(
2016-08-15 14:24:59
264
转载 分享一份很好的vim配置文件
vim强大的编辑器,官网下载不多说。这份文件可以使用gcc/g++编译,并且解决中文乱码。记得修改Path。感谢原作者的努力。set nocompatiblesource $VIMRUNTIME/vimrc_example.vimsource $VIMRUNTIME/mswin.vimbehave mswinset diffexpr=MyDiff()function MyDif
2016-08-15 08:17:36
721
原创 POJ2506Tiling
数组模拟大数这种东西。。上模板就好。。。感谢模板作者。。。#include#include#include#include#include#include#include #include using namespace std;const int Base=1000000000;const int Capacity=100;typedef long long huge;
2016-08-13 15:47:49
341
原创 POJ2524Ubiquitous Religions
裸并查集没啥说的#include#include#include#include#includeusing namespace std;int uf[50050];int find(int x){ int r=x; while(uf[r]!=r) r=uf[r]; return r;}void merge(int x,int y){ int fx
2016-08-13 14:15:02
258
原创 SDUT1047Color Me Less
#include#include#include#include#include#define MAX 0x3f3f3fusing namespace std;struct node{ double r,g,b;} a[20];double fd(struct node t,double x,double y,double z){ return sqrt((t
2016-08-11 15:10:02
270
原创 SDUT3374数据结构实验之查找二:平衡二叉树
数据额结构查找表的难题详细参考课本,总之就是四种旋转 LL RR LR RL 后两种建立在前两种旋转的基础上。取孩子节点,把孩子节点的孩子节点连到夫节点的孩子节点,再把父节点连到孩子节点上。甩代码#include#include#include#include#includeusing namespace std;struct bt{ int data,b;
2016-08-11 11:30:50
626
原创 POJ2586Y2K Accounting Bug
这道题首先跪在了英语上。。。简单的贪心题,但是思路比较特别,巨巨舍友给我讲的,每月要么盈利要么亏损,且盈利和亏损是定值。每五月统计一次,每次统计要求亏损(好奇葩)几种情况如下ssssd ssssdssssdsssssdd sssddsssddssssddd ssdddssdddsssdddd sddddsddddsd如果不属于这四种情况,也要另计算值为-1#incl
2016-08-09 22:51:10
588
原创 PTA5-1 顺序存储的二叉树的最近的公共祖先问题 (25分)
其实就是用数组模拟然后不断除二,但是要注意两个节点差很远的情况,要先单独把大下标节点缩小#include#include#include#includeusing namespace std;int main(){ int n; scanf("%d",&n); int a[1050]; for(int i=1;i<=n;i++) sc
2016-08-09 20:46:19
810
原创 POJ2109Power of Cryptography
不知道算不算一道水题,题目本身的意思应该是用数组来模拟运算,但是double的精度以及位数恰好没有超过题目数据的范围,而且开方运算中后几位和前几位相比可以忽略掉影响,所以直接可以用pow函数。#include#include#include#include#includeusing namespace std;int main(){ double a,b; whi
2016-08-09 11:01:59
310
原创 SDUT1081Above Average
水题,学会了怎么打印%#include#include#include#includeusing namespace std;int main(){ int C; scanf("%d",&C); while(C--) { int N,k=0; double a[1050],s=0; scanf("%d"
2016-08-09 10:30:02
230
原创 SDUT1075Doubles
日常水题,数组开大些,不要吝啬内存。。。会re的。。。#include#include#include#includeusing namespace std;int main(){ int t,a[10000],top=0; bool v[10000]; memset(v,false,sizeof(v)); memset(a,0,sizeof(a))
2016-08-09 09:25:18
295
原创 SDUT1009Elevator
日常水题~#include#include#includeusing namespace std;int main(){ int N; while(~scanf("%d",&N)&&N) { int a[105],s=5*N,t; a[0]=0; for(int i=1; i<=N; i++)
2016-08-09 08:50:06
272
原创 POJ1328Radar Installation
没想到一道入门贪心题都卡我一上午时间,本来打算不查题解跟它硬刚,后发现实在刚不过。。。。一开始思路就有问题,这道题需要计算左边界和右边界,然后以左边界升序排列数据。样例中的第一组数据就出现了这种情况,然而我并没有意识到。还有,在贪心计算的时候,当下一个的右边界还小于上一个的右边界时,此时边界要向后退,这个也是我没有想到的地方,总之图样图森破了。。。。Accepted 196K32MS C+
2016-08-08 15:12:34
341
1
原创 POJ2965The Pilots Brothers' refrigerator
和上一道简单枚举dfs相似,区别是需要用结构体数组模拟栈,记录位置。出栈时要用flag判断,当找到答案时就不再出栈。wa好几次,读题不精,这道题需要所有开关都是打开状态,才可以开门,以及自己是用布尔变量保存图,然而在判断时忘记了,又wa好几发。通过这两道题可以加深对dfs搜索和地柜函数的认识。Accepted164K704MSC++1324B#i
2016-08-07 16:38:50
263
原创 POJ1753Flip Game
第一道poj题,简单枚举+dfs,poj没有题解根本刚不过,代码和题解高度相似。这道题难点在于对递归的理解。step记录步数,棋盘模型决定了step上限是16,暴力枚举出每次到达相应步数的所有情况,进行判断,flag为真时找到步数,输出,结束。//测试无法找到答案时递归次数为2^16次。1753 Accepted164K 235MSC++ 1202B#includeusing
2016-08-07 15:51:31
326
原创 HDU5804&BestCoder Round #86 1001 Price List
注意数据范围,用longlong,开数组会超时,直接输出就好。#includeusing namespace std;int main(){ int T; scanf("%d",&T); while(T--) { int n,m; scanf("%d%d",&n,&m); long long int s=0;
2016-08-07 09:46:08
335
原创 SDUT数据结构实验之二叉树一:树的同构
#includeusing namespace std;struct tree{ char c; struct tree *lc,*rc;};struct node{ char s; int l,r;} a[15];struct tree * creat(int k){ struct tree *t; t=(struct tree
2016-08-06 10:17:16
1683
原创 SDUT数据结构实验之串三:KMP应用
#include#includeint n,m;int a[10000010];int b[10000010];void get_nextval(int pattern[],int next[]){ int j=0,k=-1; next[0]=-1; while(j<m) { if(k==-1||pattern[j]==pattern[k
2016-08-05 21:41:54
1777
原创 SDUT2088refresh的停车场
#includeusing namespace std;int f(char z[5]){ if(strcmp(z,"Add")==0) return 0; else if(strcmp(z,"Del")==0) return 1; else if(strcmp(z,"Out")==0) return 2;}void
2016-08-05 20:03:37
430
原创 SDUT3403数据结构实验之排序六:希尔排序
#includeusing namespace std;int a[10100],n;void shell(int dk){ int i,j; for(i=dk+1;i<=n;i++) { if(a[i]<a[i-dk]) { a[0]=a[i]; for(j=i-dk;j>0&&a[0
2016-08-05 18:39:19
332
原创 SDUT3402数据结构实验之排序五:归并求逆序数
#includeusing namespace std;int a[100010],t[100010];long long cnt;void merger0(int s1,int e1,int s2,int e2){ int p=0; int p1=s1; int p2=s2; while(p1<=e1&&p2<=e2) { if(
2016-08-05 09:43:58
870
原创 SDUT3401数据结构实验之排序四:寻找大富翁
#includeusing namespace std;void heapadjust(int a[],int i,int n){ int lc=i*2; int rc=i*2+1; int t=i; if(i<=n/2) { if(lca[t]) t=lc; if(rca[t])
2016-08-04 16:55:08
306
原创 SDUT3400数据结构实验之排序三:bucket sort
感觉此题略水#includeusing namespace std;void bucketsort(int n){ int bucket[110]; memset(bucket,0,sizeof(bucket)); for(int i=0; i<n; i++) { int t; scanf("%d",&t);
2016-08-04 14:29:52
347
原创 SDUT3399数据结构实验之排序二:交换排序
#includeusing namespace std;int s1,s2;void f1(int a[],int n){ for(int i=0; i<=n-2; i++) for(int j=0; j<=n-i-2; j++) if(a[j]>a[j+1]) { int t=a[j]
2016-08-04 11:28:36
328
原创 SDUT3404数据结构实验之排序七:选课名单
#includeusing namespace std;struct node{ char name[15]; struct node *next;};struct node *nlist[2010];int slist[2010];int main(){ int n,m; while(~scanf("%d%d",&n,&m)) {
2016-08-03 22:53:57
1852
原创 SDUT2772数据结构实验之串一:KMP简单应用
#include#includevoid get_nextval(char pattern[],int next[]){ int j=0,k=-1; next[0]=-1; while(pattern[j]!='\0') { if(k==-1||pattern[j]==pattern[k]) { j++;
2016-08-03 19:43:41
323
原创 SDUT3379数据结构实验之查找七:线性之哈希表
#includeusing namespace std;void hashf(int n,int p){ int hash0[5510]; memset(hash0,-1,sizeof(hash0)); for(int i=0; i<n; i++) { int ins,t; scanf("%d",&ins); t
2016-08-03 15:59:00
308
原创 SDUT3375数据结构实验之查找三:树的种类统计
#includeusing namespace std;int n;struct tree{ char data[22]; int cnt; struct tree *lc,*rc;};void creat(struct tree*&t,char s[]){ if(t==NULL) { t=(struct tree *)mall
2016-08-03 09:09:47
664
原创 SDUT3373数据结构实验之查找一:二叉排序树
#includeusing namespace std;struct tree{ int data; struct tree *lc,*rc;};void creat(struct tree *&node,int a){ if(node==NULL) { node=(struct tree *)malloc(sizeof(struct t
2016-08-02 21:56:43
354
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人