
杭电OJ
土方
这个作者很懒,什么都没留下…
展开
-
hdu1035-模拟问题 机器人走迷宫
1035自己写的超时了↓,不知道怎样计算循环的步数搜了别人代码,好厉害啊。。。(′へ`、 )#includeusing namespace std; int main() { int mark[12][12] = {0}; char map[12][12]; int m,n,q,x,y,p,f; bool isloop = false; while(cin>>m>>n原创 2016-07-29 10:53:09 · 447 阅读 · 0 评论 -
hdu1251-字符前缀查找问题 map容器
1251#include<iostream>#include<string>#include<map>using namespace std;int main(){ string str,str1; map<string, int> map1; while(getline(cin, str)&& str.length() !=0) { for(int i = 1; i != str.size()+1; i++)原创 2016-07-26 21:28:00 · 446 阅读 · 0 评论 -
hdu1113-字符查找问题 map容器
1113#include #include #include #include using namespace std;int main(){ map map1; map ::iterator it; string str1,str,str2; while (cin>>str && str.compare("XXXXXX")!=0) { str1 = str原创 2016-07-26 17:21:37 · 353 阅读 · 0 评论 -
hdu1201-日期问题
1201#include #include using namespace std;int isleap(int a){ if(a%4 == 0 && a%100 !=0 || a%400 == 0) return 366; else return 365; }int main(){ int t,year,month,day,sum; while (cin>>t)原创 2016-07-26 14:24:47 · 484 阅读 · 0 评论 -
hdu2057-进制转换问题
点击打开链接Sample Input+A -A+1A 121A -9-1A -121A -AA Sample Output02C11-2C-90%d 有符号32位整数%lld 有符号64位整数%llx有符号64位16进制整数%u 无符号32位整数十六进制负数在计算机里原创 2016-07-23 17:45:41 · 297 阅读 · 0 评论 -
hdu2031-进制转换问题 vector容器
2031Problem Description输入一个十进制数N,将它转换成R进制数输出。 Input输入数据包含多个测试实例,每个测试实例包含两个整数N(32位整数)和R(210)。 Output为每个测试实例输出转换后的数,每个输出占一行。如果R大于10,则对应的数字规则参考16进制(比如,10用A表示,等等)。 Sample Input7 223 12-4 3 Sampl原创 2016-07-23 10:01:04 · 348 阅读 · 0 评论 -
hdu1877-进制转换问题 vector容器
1877Input输入格式:测试输入包含若干测试用例。每个测试用例占一行,给出m和A,B的值。当m为0时输入结束。 Output输出格式:每个测试用例的输出占一行,输出A+B的m进制数。 Sample Input8 1300 482 1 70 Sample Output25041000 A+B之后的值有可原创 2016-07-22 17:31:05 · 264 阅读 · 0 评论 -
hdu1062-字符串翻转问题 reverse()
1062Sample Input3olleh !dlrowm'I morf .udhI ekil .mca Sample Outputhello world!I'm from hdu.I like acm.HintRemember to use getchar() to read '\n' after the interger T,原创 2016-07-21 17:36:31 · 437 阅读 · 0 评论 -
hdu1860-统计字符出现次数问题 string.find()
1860Sample Input I THIS IS A TEST i ng this is a long test string #Sample Output I 2 i 3 5 n 2 g 2 注:第2个测试用例中,空格也是被统计的字符之一。 string 类提供了 6 种查找函数,每种函数以不同形式的 find 命名。 这些操作全都返回 string::siz原创 2016-07-21 09:50:41 · 987 阅读 · 0 评论 -
hdu1020-统计字符出现次数问题
Sample Input 2 ABC ABBCCCSample Output ABC A2B3C 1020 出错点1: 题目只对紧挨在一起的字符统计(相当于简写),并不是所有输入的字符。如 AABAAA 输出为 2AB3A 非 5AB 出错点2: for(i = 0;i#include <iostream> #include<string>using nam原创 2016-07-19 15:32:43 · 279 阅读 · 0 评论 -
hdu1213-有多少桌子 并查集
1213 A认识B,B认识C,就相当于ABC都认识,便可以坐在一张桌子上 输入T组数,有N个人,再输入M对人关系可是为什么WA???↓ #include using namespace std; int pre[1011]; int find(int x){ return pre[x]!=x?find(pre[x]):x;}void join(int原创 2016-08-08 17:22:02 · 394 阅读 · 0 评论 -
hdu1272-小希的迷宫 并查集
1272成迷宫条件:不成环,只有一个父节点(没有孤立的点)#include using namespace std; int pre[100001]; bool t[100001],flag; //t 用于标记独立块的根结点,flag标记成环 int max1;void init(){ max1 = 0; flag =原创 2016-08-08 16:08:23 · 245 阅读 · 0 评论 -
hdu1556-color the ball 线段树
1556Sample Input3 //三组数1 1 //涂气球的区间2 23 331 11 21 30 Sample Output1 1 1 //第一个气球被涂1次颜色 第二个气球被涂2次颜色 第三个气球被涂3次颜色3 2 1#include #include using namespace转载 2016-08-13 17:38:44 · 230 阅读 · 0 评论 -
hdu1002-大数相加
1002#include #include using namespace std; string pre(string &a){ int i = 0; if (a[0]!='0') return a; while (a[i] == '0') i++; a = a.substr(i,a.length()-1); //删除前面的0,如00原创 2016-08-02 12:26:01 · 283 阅读 · 0 评论 -
hdu1402-大数相乘
1402。。又超时了 QAQ#include #include using namespace std; string pre(string &a) { int i = 0; if (a[0]!='0') return a; while (a[i] == '0') i++; a = a.substr(i,a.length()-1);原创 2016-08-02 20:16:05 · 372 阅读 · 0 评论 -
hdu1548-A strange lift BFS
1548Sample Input5 1 5 //5层楼 当前位置1楼 目标5楼3 3 1 2 5 //1楼只可以按3,不能再下,到了4楼;4楼只能按2,到了2楼;2楼按3到了五楼0 Sample Output3 // 最少按了3次键#include #include #i原创 2016-08-16 09:41:53 · 336 阅读 · 0 评论 -
hdu1372-Knight Moves BFS
1372求从他给的坐标走到另一个坐标需要多少步数,字母数字代表行列走的规则就像马走日一样(可以先横走一步再竖两步,或者竖两步横一步一共有八个方向)#include #include #include #include using namespace std; char map[9][9];int judge[9][9];int s1,s2,e1,e原创 2016-08-16 09:56:19 · 264 阅读 · 0 评论 -
hdu2553-N皇后问题 DFS
2553 横着竖着斜着都不能有两个皇后“也不允许处在与棋盘边框成45角的斜线上。”容易被这句话欺骗成以为是棋盘的两条对角线,是任意的棋子的斜方向不能有其他的皇后 思路:先确定第一行再往下递归不打表的代码,容易理解一点点嘻嘻↓#include #include #include #include using namespace std;char map[12][1原创 2016-08-16 21:59:06 · 363 阅读 · 0 评论 -
hdu1200-二维数组问题
1200题意有点难懂(´⌒`。) t o i o y --------→ | |h p k n n ←-------- | |e l e a i --------→ | |原创 2016-07-25 15:48:02 · 333 阅读 · 0 评论 -
hdu2502-月之数 注意int double范围
2502错点:要先变成double再变成int输出才不WA#include #include using namespace std;int main() { int t,n; while (cin>>t) { while (t--) { cin>>n; double原创 2016-07-25 09:31:01 · 210 阅读 · 0 评论 -
hdu2035-求N^N的后三位
2035 Sample Input 2 3 12 6 6789 10000 0 0Sample Output 8 984 1可以AC,但是大数据会爆的代码↓#include <iostream> using namespace std; int main() { int m[6],a,b,n; while (cin>>a>>b && (a!=0 || b!=原创 2016-07-20 15:59:27 · 422 阅读 · 0 评论 -
hdu1108-最小公倍数最大公约数
杭电OJ1108最小公倍数 = 最大公约数 / 两数之积#include <iostream>using namespace std;int gcd(int a,int b){ while (a!=b) { if(a>b) a = a-b; else b = b-a; } return a;}int main(){ i原创 2016-07-17 15:00:38 · 384 阅读 · 0 评论 -
hdu1021-斐波拉契问题 找规律
杭电OJ1021这个要找规律,如果..硬算的话输入999999vc都停止辣 算出前面几个数发现是12022101八个数一轮回 0 1 2 3 4 5 6 7 8 9 10 11 12 13 1 2 0 2 2 1 0 1 1 2 0 2 2 1 no no yes no no no yes no no no原创 2016-07-17 11:45:13 · 389 阅读 · 0 评论 -
hdu1048-密码问题 字符串转换
杭电1048“`include includeusing namespace std; int main() { string str1,str; while(cin>>str1) { if(str1!=”ENDOFINPUT”) { cin>>str; cin>>str1; int原创 2016-07-16 16:37:11 · 333 阅读 · 0 评论 -
hdu1008-电梯问题
杭电OJ1008上楼:输入俩楼层之差 * 6s +停留层的5s 下楼:输入俩楼层之差 * 4s +停留层的5s#include <iostream> using namespace std; int main() { int n; while(cin>>n && n!=0) { int sum,i,str[100] = {0};原创 2016-07-17 10:45:26 · 444 阅读 · 0 评论 -
hdu1061-N*N问题
1061 Problem Description Given a positive integer N, you should output the most right digit of N^N.Input The input contains several test cases. The first line of the input is a single integer T whic原创 2016-07-18 17:35:16 · 334 阅读 · 1 评论 -
hdu1863-畅通工程 最小生成树的并查集实现方法
hdu1863 ←杭电的域名换掉了,之前贴的链接都打不开Problem Description省政府“畅通工程”的目标是使全省任何两个村庄间都可以实现公路交通(但不一定有直接的公路相连,只要能间接通过公路可达即可)。经过调查评估,得到的统计表中列出了有可能建设公路的若干条道路的成本。现请你编写程序,计算出全省畅通需要的最低成本。转载 2016-08-18 16:08:14 · 288 阅读 · 0 评论 -
hdu1013-字符相加
1013 输出的数必须是一位数,24 = 2+4 =639 = 3+9 =12,12 = 1+2 =3 所以输出3--------------------------------------------------------------------------------------------------------------------------------------原创 2016-08-05 15:53:08 · 536 阅读 · 0 评论 -
hdu1166-敌兵布阵 线段树
Problem DescriptionC国的死对头A国这段时间正在进行军事演习,所以C国间谍头子Derek和他手下Tidy又开始忙乎了。A国在海岸线沿直线布置了N个工兵营地,Derek和Tidy的任务就是要监视这些工兵营地的活动情况。由于采取了某种先进的监测手段,所以每个工兵营地的人数C国都掌握的一清二楚,每个工兵营地的人数都有可能发生变动,可能增加或减少若干人手,但这些都逃不过C国的监视转载 2016-08-14 16:12:45 · 218 阅读 · 0 评论