HDU
Charles_exexex
New friend~
展开
-
HDU ACM 1.2.4 hide handkerchief
hide handkerchiefProblem DescriptionThe Children’s Day has passed for some days .Has you remembered something happened at your childhood? I remembered I often played a game called hide han原创 2017-12-21 14:13:28 · 147 阅读 · 0 评论 -
HDU 1197 Specialized Four-Digit Numbers
其实就是之前刷过的一道题:SKY数,传送门:https://blog.csdn.net/qq_39459939/article/details/83184667#include <stdio.h>#include <math.h>int calSumInSomeSystem(int DecNum, int System){ int sum = 0;...原创 2018-10-24 10:35:12 · 120 阅读 · 0 评论 -
HDU 2629 Identity Card
搞笑题,一开始因为把年月日转为了int导致个位数前面少了0而WA。后面改成生日直接提取输出就OK了。#include <stdio.h>void main(){ int num=0; scanf("%d",&num); int i=0; while(i<num) { char str[20]; scanf("%s",str); in...原创 2018-10-24 11:33:27 · 234 阅读 · 0 评论 -
HDU 2012 素数判定
素数打表基础练习,WA了3次竟然是因为最后输出之前的判断写反了。。。由于题目最大的输入只有2541,因此数组只写到2550就足够了。#include <stdio.h>int Sushubiao[2550]={0};void preCal(){ for(int i=2;i<2550/2;i++) { if(Sushubiao[i]) cont...原创 2018-10-24 15:25:40 · 161 阅读 · 0 评论 -
HDU 2016 数据的交换输出
#include <stdio.h>void FindMinAndSwitch(int *a, int n){ if(n < 1) return; int nMin=a[0],nMinId=0; for(int i=0; i < n;i++) { if(a[i] < nMin) { nMin = a[i]; nMinId=...原创 2018-11-01 15:29:00 · 102 阅读 · 0 评论 -
HDU 2020 绝对值排序
思路是开了两个数组,一个保存绝对值,一个保存符号位,排序的时候一起调换,输出的时候再把符号位乘回去就完了偷懒用了冒泡排序法#include <stdio.h>#include <iostream>using namespace std;void switchA(int num[100],int sign[100],int a,int b){ in...原创 2018-11-06 11:41:20 · 123 阅读 · 0 评论 -
HDU 2021 发工资咯
很简单,面额从大到小去减就可以了,优化一下的话就是写了个tryIndex去记录当前有可能用到的最大面额#include <stdio.h>#include <iostream>using namespace std;const int g_MoneyList[] = {100,50,10,5,2,1};void main(){ int n; ...原创 2018-11-06 11:52:17 · 139 阅读 · 0 评论 -
HDU 2022 海选女主角
很长的题目,其实很简单,就是输入一个m*n的矩阵,找出里面绝对值最大的元素,并输出行列位置信息,用了一个二维动态数组去记录输入,边输入边做最大值的判断,输入完成也就可以输出了。#include <stdio.h>#include <iostream>#include <math.h>using namespace std;void ...原创 2018-11-13 17:27:00 · 103 阅读 · 0 评论 -
HDU 2023 求平均成绩
逻辑很简单,主要是考察二维数组的使用,这里使用了二维动态数组。有一个深渊巨坑,结果计算不能用float,一定要用double,不然一直WA,应该是float的精度不够了。#include <stdio.h>#include <iostream>#include <math.h>using namespace std;void ma...原创 2018-12-27 17:02:43 · 329 阅读 · 0 评论 -
HDU 2024 C语言合法标识符
这道题是帮大家回忆合法标识符的限制条件吧。。。读入字符串两个地方需要注意,第一个是输入完数量之后需要一个getchar来读取回车符第二个是读入一整行字符需要用gets#include <stdio.h>#include <iostream>#include <math.h>using namespace std;void ma...原创 2018-12-27 17:19:36 · 107 阅读 · 0 评论 -
HDU 2026 首字母变大写
题目里面确实所有字母都是小写,没有那种本来就是大写的坑。值得留意的是可能会出现多个连续的空格(也不一定,我自己测试的时候添加判断了),这个我处理了也就是上一个不是字母并且当前是字母,才变大写。#include <stdio.h>#include <iostream>#include <math.h>using namespace ...原创 2018-12-27 17:57:01 · 118 阅读 · 0 评论 -
HDU 2028 Lowest Common Multiple Plus
这道题有意思,大致的思路有两种:1、多个数求最小公倍数//解题思路://先排序,然后求两个数的最小公倍数,然后把结果再与下一个数进行求最小公倍数//最小公倍数等于两个数相乘除以他们的最大公约数但是这会TLE。。。2、还是用简单粗暴的方法吧。。。//直接找最大的数,然后翻倍,看是不是所有的其他数的倍数就好了然鹅还是TLE。。。 3、边输入边找,算出一开始输入的...原创 2019-01-04 17:31:11 · 125 阅读 · 0 评论 -
HDU 2030 汉字统计
按照提示,学习了汉字机内码,其实特点就是高位为1,所以将一个字节转成整形的时候,会小于0有个坑查了半天,读取字符串时不能用scanf,因为使用scanf的话就读不到空格了!!!要使用gets!!!#include <stdio.h>#include <iostream>#include <math.h>using namespace ...原创 2019-01-11 15:40:11 · 122 阅读 · 0 评论 -
HDU 2032 杨辉三角
基础题杨辉三角,直接二维数组,先预先生成30层杨辉三角,然后直接输出即可还是输入的坑,在while里面没有判断scanf是否等于EOF导致出现了OLE,出OLE的时候自己也猜测是因为最后多输出了一个空行。。。#include <stdio.h>#include <iostream>#include <math.h>#include <f...原创 2019-01-11 16:36:38 · 172 阅读 · 0 评论 -
HDU 2040 亲和数
一道没想到居然没有超时的题,思路就是找小的那个数,然后取一半一直往下递减,找到所有约数的和,然后和较大的数比较是否相等。#include <stdio.h>#include <iostream>#include <math.h>#include <fstream>using namespace std;void main...原创 2019-01-11 16:52:32 · 135 阅读 · 0 评论 -
HDU 2042 不容易系列之二
题目太长就懒得截图了,题目的大义其实就是一个数列最后一个项是3,然后前一个项是(后一个项-1)*2,给你项的总数,让你求第一个项。所以就很简单啦,由于项的数量不超过31个(算上最后一个3),所以也不会超过INT_MAX(2*10^9)。记得一开始打表哦~#include <stdio.h>int glb_sheep[31]={0};void prepare(...原创 2019-02-28 11:57:33 · 96 阅读 · 0 评论 -
HDU 1170 Balloon Comes!
题意很简单,要注意的是,使用了scanf(“%c”,&op)之后,需要用一个getchar()来读取最后输入的换行符,而平常输入%d的时候则不需要。#include <stdio.h>#include <math.h>#include <iostream>using namespace std;void main(){ i...原创 2018-10-24 10:22:28 · 90 阅读 · 0 评论 -
HDU 2015 偶数求和
关键在于判断一下每次求平均的结束点#include <stdio.h>void main(){ //先构建数列 int a[100]; for(int i=0;i < 100;i++) a[i]=(i+1)*2; int n,m; while(scanf("%d %d",&n,&m) != EOF) { int cnt =...原创 2018-10-29 11:50:43 · 162 阅读 · 0 评论 -
HDU 2104 hide handkerchief
简单数学题,容易退出题意其实就是要求给的两个数是不是互质,然后用GCD求两个数的最大公约数,是1的话就YES,否则NO#include <stdio.h>#include <math.h>#include <iostream>using namespace std;//题意/*给定了数组的长度,还有单步移动的距离,判断能否遍历数组需要...原创 2018-10-23 17:49:38 · 119 阅读 · 0 评论 -
HDU ACM 1.2.6 The Seven Percent Solution
HomeProblemRanklistStatusFriends RankFriends Status欢迎参加——2017印象盐城大数据竞赛!The Seven Percent SolutionTime Limit: 2000/1000 MS (Java/Others) Memory原创 2017-12-27 15:16:53 · 216 阅读 · 0 评论 -
HDU ACM 1.2.1 Elevator
ElevatorTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 7474 Accepted Submission(s): 3673 Problem Description原创 2017-12-27 15:39:42 · 203 阅读 · 0 评论 -
HDU ACM 1.2.2 A+B Coming
A+B ComingTime Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 7516 Accepted Submission(s): 3406 Problem Description原创 2017-12-27 15:58:13 · 216 阅读 · 0 评论 -
HDU ACM STEP 1.2.8 ASCII
ASCIITime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 5136 Accepted Submission(s): 2360Problem DescriptionSi原创 2018-01-15 12:35:05 · 153 阅读 · 0 评论 -
HDU ACM 1.2.3 Text Reverse
Text ReverseTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 10139 Accepted Submission(s): 2741 Problem Descriptio原创 2018-01-15 14:24:04 · 327 阅读 · 0 评论 -
HDU ACM STEP 1.3.8 As Easy As A+B
As Easy As A+BTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 4137 Accepted Submission(s): 1895 Problem Descripti原创 2018-01-16 14:41:56 · 135 阅读 · 0 评论 -
HDU 2000 ASCII码排序
很简单,要注意的是读入字符的时候,要考虑空格、换行、回车等字符#include <stdio.h>void switch_a(char &a, char &b){ char tmp; tmp = a; a = b; b = tmp;}void main(){ char a,b,c,e; char str[4]; while(sc...原创 2018-10-18 12:04:50 · 74 阅读 · 0 评论 -
HDU 2005 第几天
可以参考的是月份天数打表,以及字符串分解的动作V#include <stdio.h>#include <math.h>bool isRunnian(int year){ return ((year%4==0 && year%100!=0) || year%400==0)?true:false;}int monthday[]={31,...原创 2018-10-19 14:58:17 · 80 阅读 · 0 评论 -
HDU 2007 平方和与立方和
一个小坑,输入的两个数字,有可能是第一个比第二个大,比如说3 1,要注意把输入的两个数字进行大小比较#include <stdio.h>#include <math.h>void main(){ int a,b; while(scanf("%d %d",&a,&b) != EOF) { int oddProduct=0, ev...原创 2018-10-19 15:13:12 · 82 阅读 · 0 评论 -
HDU 2010
注意一下输入的m和n大小顺序,以及输出的空格就行了#include <stdio.h>#include <math.h>void main(){ int a,b; while(scanf("%d %d",&a,&b) != EOF) { if(a > b) { a = a^b; b = a^b; a...原创 2018-10-19 15:55:34 · 258 阅读 · 0 评论 -
HDU 2011 多项式求和
首先就想到了打表,可能不打表会TLE咯(没试过)。。。#include <stdio.h>#include <math.h>void preCal(float biao[1001]){ biao[0] = 0; float nFactor = 1; for(int i = 1;i <= 1000;i++) { biao[i] = biao...原创 2018-10-19 16:08:26 · 84 阅读 · 0 评论 -
HDU 2039 三角形
很无聊,但是忘记了输入可以是小数,WA了两次,看题还是不够仔细啊#include <stdio.h>#include <math.h>void main(){ int n; scanf("%d",&n); int i=0; while(i < n) { float a,b,c; scanf("%f %f %f",&...原创 2018-10-19 16:20:56 · 91 阅读 · 0 评论 -
HDU 2097 Sky数
做这道题全因为这个题目,Sky~其实就是考你10进制转其他进制的算法,写了一个通用的函数,KO~#include <stdio.h>#include <math.h>int calSumInSomeSystem(int DecNum, int System){ int sum = 0; int a = DecNum, b=System; int ...原创 2018-10-19 16:41:48 · 116 阅读 · 0 评论 -
HDU 1720 A+B Coming
要注意输入可能是个字符串,还有大小写识别。#include <stdio.h>#include <math.h>int HexToDec(char a[100]){ int nDec=0; for(int i = 0; a[i] != '\0';i++) { char c = a[i]; int n = 0; if( c >= ...原创 2018-10-22 11:30:59 · 81 阅读 · 0 评论 -
HDU 1062 Text Reverse
我的思路还是通过空格一个个子串找出来,然后交换位置。字符串最后\0的判断踩了个坑WA了一次。。。#include <stdio.h>#include <math.h>#include <iostream>using namespace std;void ReverseTarget(char str[1001],int beg,int ...原创 2018-10-23 17:27:38 · 116 阅读 · 0 评论 -
HDU ACM 2055 An easy problem
题目很简单,坑在于当你想用C的scanf去获取第一个字符的时候,scanf("%c %d",&c,&a),会出现两个都获取失败。原因在于scanf %c是回车后从缓存里读取第一个字符,这里读出来的是什么我也不知道,反正就出问题了。然后尝试用 c = getche()来读取第一个字符,getchar()来处理掉中间的空格,然后scanf()读取最后的数字,效果是OK的,...原创 2019-05-13 12:01:58 · 136 阅读 · 0 评论