
ACM
Start-ZJ
苦逼大学生,技术菜如狗,码力百分五。
展开
-
HDU Ignatius and the Princess III
#include <stdio.h>#include <string.h>int main(int argc, char *argv[]){ int c1[1005],c2[1005]; int i,j,k; int n; while(scanf("%d",&n)!=EOF) { memset(c1,0,sizeof(c1)); memset...原创 2018-03-12 19:13:32 · 129 阅读 · 0 评论 -
HDU 1862 EXCEL排序
//太简单了,没什么好说的#include <stdio.h>#include <string.h>#include <algorithm>#include <math.h>using namespace std;struct node { int num; char name[10]; int A;}a...原创 2017-11-30 12:07:58 · 210 阅读 · 0 评论 -
HDU 2093 考试排名
//题意自己看,应该都懂得#include <stdio.h>#include <algorithm>#include <string.h>#include <math.h>using namespace std;struct node { char name[15]; int ac; int time;}student[...原创 2017-11-30 11:54:34 · 179 阅读 · 0 评论 -
HDU 1233 还是畅通工程 (并查集)
#include <bits/stdc++.h>using namespace std;const int maxn=10005; struct node{ int f; int l; int len;}a[maxn];//定义一个结构体储存公路的信息 int n,m,b[maxn],ans;bool cmp(node a,node b){ return a....原创 2017-11-14 20:23:00 · 222 阅读 · 0 评论 -
HDU 1213 How Many Tables (并查集)
//题意自己看,不会度娘#include <stdio.h>#include <string.h>int a[1050];int merge(int x){ int r=x; while(a[r]!=r) r=a[r]; return r;}void findx(int x,int y){ int fx=merge(x); int fy=...原创 2017-11-14 19:43:00 · 159 阅读 · 0 评论 -
马的移动 (BFS)
//题意自己看,不会度娘#include <stdio.h>#include <queue>#include <string.h>struct node{ int x; int y; int step;};int map[8][8];//标记数组 int sx,sy,ex,ey,ans;int move[8][2]={1,2,1,-...原创 2017-10-23 11:21:10 · 694 阅读 · 0 评论 -
HDU 1518 Square (DFS)
//题意不会度娘#include <stdio.h>#include <algorithm>#include <string.h>#include <iostream>using namespace std;bool visit[25];int a[25];int sum;int n,k;bool cmp(int a,int...原创 2017-10-17 19:33:49 · 255 阅读 · 0 评论 -
HDU 1584 蜘蛛牌
//题意自己看,不会度娘#include <bits/stdc++.h>using namespace std;int a[100],mark[100];int mmp;void DFS(int num,int sum){ if(sum>=mmp)//如果目前移动距离已经超过或等于记录的最小移动距离 return ; if(num==9)//10个数...原创 2017-09-28 15:59:32 · 231 阅读 · 0 评论 -
HDU 1426 Sudoku Killer (DFS)
//题意自己看,不会度娘#include <stdio.h>struct mmp{ int x; int y;}we[81];//结构体代表数独图里的坐标 int map[9][9],num,flag;int cheak(int k,int step)//k代表放入的数,检查在9*9和3*3的图中,行和列里是否有相同的数 { int i,j; for(i=...原创 2017-09-28 14:08:26 · 192 阅读 · 0 评论 -
HDU 1342 Lotto (DFS)
//题意自己看,不会度娘#include <stdio.h>#include <string.h>#include <math.h>int a[20],b[10];int n;void DFS(int num,int s){ if(num==7)//num到7说明已经符合大乐透6位数的要求,开始输出 { for(int i =1 ;...原创 2017-09-28 14:02:17 · 204 阅读 · 0 评论 -
HDU 1015 Safecracker (DFS)
//题意自己看,不会度娘#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>using namespace std;char a[15];char b[15];int n,num,len;int visit[15];bool mm...原创 2017-09-28 13:47:41 · 234 阅读 · 0 评论 -
HDU 1312 Red and Black (DFS)
#include <stdio.h>#include <string.h>#include <math.h>char map[21][21];int w,h;int dx[]={-1,0,1,0};int dy[]={0,1,0,-1};//两个数组控制上下左右 int sum;void DFS(int x,int y){ if(x<...原创 2017-09-22 09:25:52 · 192 阅读 · 0 评论 -
HDU 1181 变形课(DFS)
#include <stdio.h>#include <string.h> char start[1024];//字母开头储存 char end[1024];//字母结尾储存 int flag[1024];//标记 int n;int visit;void DFS(char x){ if(x=='m')//如果x的值是m表明咒语符合要求。标记为一。 ...原创 2017-09-21 18:29:08 · 245 阅读 · 0 评论 -
HDU 1175 连连看 (DFS)
//题意自己看,不懂度娘#include <stdio.h>#include <string.h>int map[1010][1010];//数组范围要注意,有个很蠢的人就错在这(不是我)int visit[1010][1010];int x,y,sx,sy,ex,ey;int dicx[]={1,-1,0,0};int dicy[]={0,0,1,-1};...原创 2017-09-21 18:24:31 · 244 阅读 · 0 评论 -
HDU 1010 Tempter of the Bone (DFS)
//题意自己看,不会度娘#include <stdio.h>#include <math.h>#include <string.h>char map[10][10];int si,sj,di,dj,is,T,n,m,word;int dx[]={-1,0,1,0};int dy[]={0,1,0,-1};//四个方向void DFS(int...原创 2017-09-20 15:47:41 · 169 阅读 · 0 评论 -
HDU 1242 Rescue (DFS)
//题意自己看,不会度娘#include <stdio.h>#include <math.h>#include <string.h>char map[205][205];//地图int flag[205][205];//标记int n,m,ok,num;void DFS(int x,int y,int step){ if(flag[...原创 2017-09-20 15:37:33 · 215 阅读 · 0 评论 -
HDU 2553 N皇后问题 (DFS)
/题意自己看,不会度娘#include <stdio.h>#include <string.h>#include <math.h>int qizi[20];int flag[20];int n;int num;int judge(int hang){ for(int i=1;i<hang;i++)//循环行 { ...原创 2017-09-20 14:48:39 · 178 阅读 · 0 评论 -
HDU 1009 FatMouse' Trade (贪心)
//题意自己看,不会度娘,很裸的贪心,没啥好说的#include <stdio.h>#include <string.h>#include <algorithm>#include <math.h>using namespace std;struct node{ double jb; double ds; double nu...原创 2017-12-05 11:17:40 · 189 阅读 · 0 评论 -
HDU 1053 Entropy(贪心)
这道题是哈弗曼树+贪心;哈夫曼树:哈夫曼树又称最优二叉树,是一种带权路径长度最短的二叉树。所谓树的带权路径长度,就是树中所有的叶结点的权值乘上其到根结点的路径长度(若根结点为0层,叶结点到根结点的路径长度为叶结点的层数)。树的带权路径长度记为WPL=(W1*L1+W2*L2+W3*L3+...+Wn*Ln),N个权值Wi(i=1,2,...n)构成一棵有N个叶结点的二叉树,相应的叶结点的路...原创 2017-12-12 19:36:31 · 335 阅读 · 0 评论 -
HDU 2062 Subset sequence (数学)
一道数学题,很有趣,看了很多题解才懂。首先是要求出An数组的子集和有多少个。数学拙鸡就不写推导过程了,有兴趣可以自己去搜。A[n]=(A[n-1])*(n-1)+1;引用一段解释的很好的过程解释来说下3 10 这组数据是怎么处理的(语文拙计)因为n=3,所以开始数组里1、2、3三个数。我们知道,n=2时,有4种排列,所以上面n=3可以分成三组,每组5个(加上空集)。因此第1...原创 2017-12-14 10:01:52 · 308 阅读 · 0 评论 -
HDU 1398 Square Coins [母函数]
Square CoinsTime Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other)Total Submission(s) : 25 Accepted Submission(s) : 21Problem DescriptionPeople in Silverland use square coi...原创 2018-03-12 19:18:27 · 130 阅读 · 0 评论 -
HDU 1085 Holding Bin-Laden Captive! [母函数]
Holding Bin-Laden Captive!Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other)Total Submission(s) : 30 Accepted Submission(s) : 15Problem DescriptionWe all know that Bin-...原创 2018-03-12 19:21:22 · 125 阅读 · 0 评论 -
HDU 1171 Big Event in HDU [母函数]
Big Event in HDUTime Limit : 10000/5000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other)Total Submission(s) : 51 Accepted Submission(s) : 14Problem DescriptionNowadays, we all know that Com...原创 2018-03-12 19:27:46 · 118 阅读 · 0 评论 -
HDU 1709 The Balance [母函数]
The BalanceTime Limit : 1000/1000ms (Java/Other) Memory Limit : 32768/32768K (Java/Other)Total Submission(s) : 13 Accepted Submission(s) : 6Problem DescriptionNow you are asked to measure a dose o...原创 2018-03-12 19:35:33 · 158 阅读 · 0 评论 -
HDU 2082 找单词[母函数]
找单词Time Limit : 1000/1000ms (Java/Other) Memory Limit : 32768/32768K (Java/Other)Total Submission(s) : 11 Accepted Submission(s) : 8Problem Description假设有x1个字母A, x2个字母B,..... x26个字母Z,同时假设字母A的价值为1,...原创 2018-03-12 19:51:47 · 127 阅读 · 0 评论 -
HDU 2151 Fruit [母函数]
FruitTime Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 5428 Accepted Submission(s): 3175Problem Description转眼到了收获的季节,由于有TT的专业指导,Lele获得了大丰收。特别是水...原创 2018-03-12 19:56:45 · 214 阅读 · 0 评论 -
HDU 2079 选课时间(题目已修改,注意读题) [母函数]
选课时间(题目已修改,注意读题)Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 5661 Accepted Submission(s): 4296Problem Description又到了选课的时间了,xhd看着选课表发呆,为了想让...原创 2018-03-12 20:06:49 · 157 阅读 · 0 评论 -
1203 HDU I NEED A OFFER! [01背包]
#include <stdio.h>#include <string.h>#include <algorithm>using namespace std;int main(int argc, char *argv[]){ int n,m; int i,j; int a[10005]; double dp[200005],b[10005]; ...原创 2018-03-22 09:04:53 · 134 阅读 · 0 评论 -
HDU 1171 Big Event in HDU [多重背包]
#include <stdio.h>#include <string.h>#include <math.h>#include <algorithm>using namespace std;int ttt[5005];int dp[255555];int main(int argc, char *argv[]){ int n,a,b...原创 2018-03-22 09:02:45 · 108 阅读 · 0 评论 -
HDU 2546 饭卡 [01背包]
#include <stdio.h>#include <string.h>#include <math.h>#include <algorithm>using namespace std;int main(int argc, char *argv[]){ int n,m; int i,j; int a[3005],dp[3005]...原创 2018-03-22 08:59:38 · 115 阅读 · 0 评论 -
01,完全,多重背包模板
//01背包模板//假设a[i]代表质量,b[i]代表价值,dp[n]代表在背包大小为n时的最优解 //n代表物品数量,m代表背包大小//则: for(i=1;i<=n;i++) for(j=m;j>=a[i];j--) dp[j]=max(dp[j],dp[j-a[i]]+b[i]);//同理,//完全背包模板 for(i=1;i<=n;i++) ...原创 2018-03-22 08:56:24 · 99 阅读 · 0 评论 -
HDU 2544最短路 [最短路]
最短路Time Limit: 5000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 78016Accepted Submission(s): 33930Problem Description在每年的校赛里,所有进入决赛的同学都会获...转载 2018-03-08 11:36:27 · 134 阅读 · 0 评论 -
HDU 2602 Bone Collector(0 1背包)
//题意自己看,不会度娘#include <stdio.h>#include <string.h>#include <algorithm>#include <math.h>using namespace std;int main(int argc, char *argv[]){ int i,j; int t,n,v,n1[10...原创 2017-12-21 19:31:47 · 152 阅读 · 0 评论 -
HDU 1160 FatMouse's Speed (DP)
这道题的思路想通了就很简单。不需要DP转移公式,想多了,一直想推出来反而写错了。明明刘春英讲DP的时候已经想通了还是会错,还是练得少啊。根据题意的意思就是要先将数据按体重递增,速度递减排序后找最长子序列。所以推荐用sort函数排好后循环判断就好。不过题目要求的是输出数据的位置,所以还要定义一个结构体去储存下。//题意自己看,不会度娘#include <stdio.h&...原创 2017-12-19 10:34:07 · 173 阅读 · 0 评论 -
HDU 1421 搬寝室 (DP)
//题意自己看,不会度娘#include <stdio.h>#include <math.h> #include <algorithm>#include <string.h>using namespace std;int dp[2005][1005];//i代表有几个东西,j代表有几对 int main(int argc, cha...原创 2017-12-18 19:40:39 · 235 阅读 · 0 评论 -
HDU 2064 汉诺塔III (递归)
//题意自己看,不懂度娘#include <stdio.h>#include <algorithm>#include <math.h>#include <string.h>using namespace std;int main(int argc, char *argv[]){ int m; long long int a[...原创 2017-12-14 10:41:39 · 269 阅读 · 0 评论 -
HDU 1241 Oil Deposits (DFS 八方向)
//杭电1241//题意自己看,不会度娘#include <stdio.h>#include <math.h>#include <string.h>int n,m,flag[105][105],num;char cmp[105][105];int spx[]={0,1,0,-1,1,1,-1,-1};int spy[]={1,0,-1,0,...原创 2017-09-20 14:32:35 · 240 阅读 · 0 评论