- 博客(52)
- 收藏
- 关注
原创 杭电题目分类
基础题:1000、1001、1004、1005、1008、1012、1013、1014、1017、1019、1021、1028、1029、1032、1037、1040、1048、1056、1058、1061、1070、1076、1089、1090、1091、1092、1093、1094、1095、1096、1097、1098、1106、1108、1157、1163、1164、1170、1194、1
2016-04-25 20:20:44 257
原创 hdu1302The Snail
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1302这道题真的醉了。。代码:#include int main(){ double h,u,d,f; while(~scanf("%lf%lf%lf%lf",&h,&u,&d,&f),h) { double sum =
2016-04-25 19:09:49 395
原创 hdu1248寒冰王座
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1248就是一个完全背包的模板题,水水水。代码:#include #include #include using namespace std;int n;int c[] = {150,200,350};int w[] = {150,200,350};int
2016-04-25 17:44:11 242
原创 hdu1236排名
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1236水水代码:#include #include #include using namespace std;int n,m,g;int s[15];struct Node { char num[30]; int a; int scor
2016-04-24 11:42:49 297
原创 hdu1219AC Me
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1219for(int i = 0;i 代码:#include #include char s[100005];int a[30];int main(){ while(gets(s)) { memset(a,0,sizeof(a)
2016-04-24 11:25:06 362
原创 hdu1202The calculation of GPA
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1202继续水水水水水。代码:#include #include struct Node{ double s; double p; double gp;}a[1000000];int main(){ int _; whi
2016-04-24 11:01:40 297
原创 hdu1194Beat the Spread!
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1194思路:如果绝对值比和还大就不可能,然后就可以暴力枚举了。代码:#include int abs(int n){ return n > 0 ? n : -n;}int main(){ int _; while(~sca
2016-04-24 10:30:28 340
原创 hdu1170Balloon Comes!
水题我都不想贴题目链接了。代码#include #include char c;char a[10],b[10];int main(){ int _; scanf("%d",&_); while(_--) { getchar(); scanf("%c%s%s",&c,a,b);
2016-04-24 09:59:56 282
原创 hdu1164Eddy's research I
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1164素数筛了。代码:#include int prime[1000000];void init(){ for(int i = 2;i <= 65535;++i) prime[i] = 1; for(int i = 2;i <=
2016-04-23 23:37:42 303
原创 hdu1163Eddy's digital Roots
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1163九余数定理:一个数的每位数字之和如果不小于10,那么就继续相加,直到小于10,相当于这个数对9取余。代码:#include int main(){ int n; while(~scanf("%d",&n),n) {
2016-04-23 17:09:55 262
原创 hdu1070Milk
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1070水。代码:#include #include #include using namespace std;struct Node{ char s[105]; int price; int v; double perPrice;
2016-04-23 00:37:22 349
原创 hdu1061Rightmost Digit
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1061快速幂模板题#include const int mod = 1e5;typedef long long ll;ll quickAns(ll a,ll b){ ll res = 1; while(b) { if(b &
2016-04-22 23:50:49 258
原创 HDU1058Humble Numbers
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1058水水更健康。。代码:#include #include #include using namespace std;typedef long long ll;ll ans[6000];ll prime[] = {2,3,5,7};void init()
2016-04-22 23:26:53 228
原创 NYOJ108士兵杀敌(一)
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=108一开始竟然用的vector保存的第i项到第j项的和,果断爆掉了内存呢,我真的是醉了。。用一个数组保存前K项的和,例如 b[k] = a[1] + ... + a[k] 的和,然后就不说了,都是泪。。代码:#include #include
2016-04-22 17:03:04 571
原创 NYOJ4324 Point game(DFS)
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=43思路是模仿别人的。思路:每次从数组中选出来两个数,做完四则运算在放回去,直到剩最后一个数,和给定的值比较。代码:#include #include double number[10];int m,n;bool dfs(int e
2016-04-20 19:51:03 269
原创 NYOJ239月老的难题
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=239把男孩的编号都加上个n,然后用vector,神奇就过了。代码:#include #include #include using namespace std;int n,k;vector e[1005];int v[1005];int matc
2016-04-20 18:35:15 314
原创 NYOJ2444The Accomodation of Students
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2444就是一个匈牙利算法模板题。代码:#include #include #include using namespace std;int n,m;int e[205][205];int col[205];int match[205];int v[205]
2016-04-20 18:03:04 94
原创 hdu1045FireNet
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1045思路:一行一行的搜索,如果当前为‘X' ,就搜下一个,如果当前为'.' ,判断能不能放一个装置,如果不能,直接搜索下一个,如果能,也要分两种情况,一种放,一种不放。代码(有点长,但是好理解):#include #include char s[10][10]
2016-04-18 23:09:03 421
原创 二分图的最大匹配算法
二分图的最大匹配又称匈牙利算法,顾名思义,就是在二分图找最多的匹配个数。算法思想:1.首先从一个没有匹配的任意顶点u,从点u的任意一条边(假设是u -> v),如果此时v没有被匹配,则配对成功, 记作 match[u] = v; match[v] = u;
2016-04-18 19:07:41 960 1
原创 二分图的判定
二分图:一个图的顶点可以分两个集合A和B,所有的边的两个顶点一个来自于A,另一个来自于B,且每个集合中的顶点相互没有边。由于顶点比较多,所以采用了vector来存储图;#include #include #include #include using namespace std;const int maxn = 1e4;vector e[maxn + 5];
2016-04-18 18:22:12 343
原创 NYOJ364田忌赛马
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=364思路:1.当田忌的快马比齐王的快马块时,赢一场 2.当田忌的慢马比齐王的慢马快时,赢一场 3.当1和2都不满足时,用田忌的慢马去和齐王的慢马去比。代码:#include #include #include
2016-04-17 21:34:22 322
原创 NYOJ103A+B Problem II
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=103纯模拟,没啥好说的 - -#include #include #include using namespace std;char s[1010];char s1[1005];int s2[1005];int len_s;int len_s1;vo
2016-04-17 13:37:47 245
原创 NYOJ10skiing
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=10我的第一种方法是对矩阵的每个顶点当作起点搜索一遍,结果是用时260MS,代码:#include #include using namespace std;#define inf 1e6int mp[105][105];int r,c;int v[105]
2016-04-17 12:26:32 339
原创 NYOJ1100WAJUEJI which home strong!
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=1100BFS + 优先队列! 自定义优先级!!!!!代码:#include #include #include using namespace std;typedef struct Node{ int x,y; char c;
2016-04-16 19:57:29 527
原创 NOOJ927The partial sum problem
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=927这也算是个0-1背包的思想的吧。加上剪枝。代码:#include #include #include using namespace std;int n,k;int a[25];bool dfs(int cur,int sum){
2016-04-14 21:07:40 285
原创 NYOJ38布线问题
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=38任意选择一个起点求最小生成树,然后最后在加上某个花费最少的点,算法选择普里姆算法.#include #include #define inf 0x3f3f3f3fint mp[505][505];int v,e;int ans;int d[505]
2016-04-14 19:22:53 643
原创 NYOJ73比大小
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=73每种情况不要落下就好了。#include #include char s[1005];char s1[1005];int len_s,len_s1;bool isEnd(){ len_s = strlen(s); len_s1 = str
2016-04-14 18:10:24 262
原创 NYOJ68三点顺序
叉积面积小于0,逆时针,大于0,顺时针。代码:#include #include int main(){ int x1,y1,x2,y2,x3,y3; while(~scanf("%d%d%d%d%d%d",&x1,&y1,&x2,&y2,&x3,&y3),x1+y1+x2+y2+x3+y3) { int tx = x3 - x1;
2016-04-13 20:32:23 337
原创 NYOJ67三角形面积
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=67一个海伦公式,不解释。#include #include double dis(double x1,double y1,double x2,double y2){ return sqrt(pow(x1 - x2,2) + pow(y1 - y2,
2016-04-13 20:04:20 305
原创 NYOJ1112求次数
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=1112用set水了好几遍才过的。。。#include #include #include #include using namespace std;set st;int main(){ int t; scanf("%d",&t);
2016-04-13 19:22:34 395
原创 NYOJ991Registration system
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=991还是STL中的set头文件#include using namespace std;声明:set s.如果来了一个字符串a,用s.count(a)判断s中是否存在a,如果不存在a,直接输出OK并用s.insert(a)把a插入到s中,如果存在了,就从a1一直往
2016-04-13 18:26:48 338
原创 NYOJ412Same binary weight
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=412思路:从n的二进制中从右往左寻找第一个01,然后将01右边的1全都移到最右边;用的是bitset声明: bitset bt(n) 代表n的二进制存在了bt中,bt[i]上的数字代表n的二进制中的各个数字,bt.to_ulong()是将bt以无符号长整型输出出
2016-04-13 17:50:59 375
原创 NYOJ95众数问题
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=95vector不解释。每次要清空vector代码:#include #include #include using namespace std;const int maxn = 1e5;vector ans[maxn + 5];in
2016-04-11 23:29:39 342
原创 NYOJ93汉诺塔(三)
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=93用栈模拟就好了。代码:#include #include using namespace std;int p,q;int flag;struct Node{ stack st;}a[5];int fr[105],too[105];vo
2016-04-11 22:57:20 352
原创 NYOJ86找球号(一)
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=86这道题两种解法,一个是二分查找,一个是用set。注意:这道题数据不是读到文件尾,超时的小伙伴看过来。 二分: #include #include using namespace std;const int maxn = 1e8;
2016-04-11 22:12:16 275
原创 HDU2188 && HDU2149 && HDU1846
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2188把这个题倒过来想,假如现在募捐箱里面有n元钱,两个人每次至少取一元钱,最多取m元钱,最后一个取光的人为胜者,就是一个简单的巴什博弈。巴什博弈:有一堆n个物品,两个人轮流从这堆物品中取物,规定每次至少取一个,最多取m个,最后取光者得胜。1.我们现在想想假如现在局面上就剩下
2016-04-11 20:10:06 282
原创 NYOJ55懒省事的小明
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=55这个题和石子合并有一定区别,这个是任意两堆都可以合并,所以贪心就好了,每次合并两堆重量最小的,优先队列!!代码:#include #include using namespace std;typedef long long ll;prior
2016-04-11 19:03:54 775
原创 NYOJ19擅长排列的小明
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=19一个深搜就搞定了。。代码:#include #include int n,m;int a[15];int v[15];void dfs(int step){ if(step == m + 1) { for(int
2016-04-11 18:34:31 277
原创 NYOJ36最长公共子序列
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=36纯模板。。代码:#include #include #include using namespace std;char s[1005];char s1[1005];int dp[1005][1005];int main(){
2016-04-11 18:02:48 440
原创 NYOJ8一种排序
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=8STL sort的模板题,注意一下输入的时候长和宽的问题。。代码:#include #include using namespace std;struct Node{ int number; int length; int wi
2016-04-10 22:35:54 223
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人