前言(废话)

从11月6号到11月20号,断断续续做了有三个星期,总算整完了,之后会慢慢整理汇总到这里

中间部分用到数学知识的十几道题边学边做直接把我这个数学菜鸟做到怀疑人生

11.6~11.10又恰逢暨南大学华为杯网络安全挑战赛,一日三餐均为面包,从早肝到晚,肝了5天,累到半死。也因此颓了一周

有的题会重要写一下思路,大部分题题解应该会比较简单不会赘述(有的跨时太久可能也忘了

如有不正确的地方还请不吝赐教,我会十分感谢

下面进入正题

Problem Description

输入三个字符后,按各字符的ASCII码从小到大的顺序输出这三个字符。

Input

输入数据有多组,每组占一行,有三个字符组成,之间无空格。

Output

对于每组输入数据,输出一行,字符中间用一个空格分开。

Sample Input

qwe

asd

zxc

Sample Output

e q w

a d s

c x z

十分单纯的比较大小问题,直接上代码

  1. #include <iostream>
  2. #include <cstdio>
  3. #include <cmath>
  4. #include <cstring>
  5. #include <algorithm>
  6. using namespace std;
  7. char a, b, c;
  8. int main() {
  9. while (scanf("%c%c%c", &a, &b, &c) != EOF) {
  10. getchar();
  11. if (a > b) {
  12. char d = a;
  13. a = b;
  14. b = d;
  15. }
  16. if (a > c) {
  17. char d = a;
  18. a = c;
  19. c = d;
  20. }
  21. if (b > c) {
  22. char d = b;
  23. b = c;
  24. c = d;
  25. }
  26. printf("%c %c %c\n", a, b, c);
  27. }
  28. return 0;
  29. }

Problem Description

输入两点坐标(X1,Y1),(X2,Y2),计算并输出两点间的距离。

Input

输入数据有多组,每组占一行,由4个实数组成,分别表示x1,y1,x2,y2,数据之间用空格隔开。

Output

对于每组输入数据,输出一行,结果保留两位小数。

Sample Input

0 0 0 1

0 1 1 0

Sample Output

1.00

1.41

十分简单的小学数学问题,不多说

  1. #include <iostream>
  2. #include <cmath>
  3. #include <cstring>
  4. #include <cstdio>
  5. #include <algorithm>
  6. using namespace std;
  7. double x1, x2, z1, z2;
  8. double ans;
  9. int main() {
  10. while (scanf("%lf%lf%lf%lf", &x1, &z1, &x2, &z2) != EOF) {
  11. ans = sqrt((x1 - x2) * (x1 - x2) + (z1 - z2) * (z1 - z2));
  12. printf("%.2lf\n", ans);
  13. }
  14. return 0;
  15. }

Problem Description

根据输入的半径值,计算球的体积。

Input

输入数据有多组,每组占一行,每行包括一个实数,表示球的半径。

Output

输出对应的球的体积,对于每组输入数据,输出一行,计算结果保留三位小数。

Sample Input

1

1.5

Sample Output

4.189

14.137

Hint

"#define PI 3.1415927"

体积大概是高中数学?算就完事

  1. #include <iostream>
  2. #include <cstdio>
  3. #include <cmath>
  4. #include <cstring>
  5. #include <algorithm>
  6. #define PI 3.1415927
  7. using namespace std;
  8. double r, ans = 1.0;
  9. int main() {
  10. while (scanf("%lf", &r) != EOF) {
  11. ans = PI * r * r * r * (4.0 / 3);
  12. printf("%.3lf\n", ans);
  13. }
  14. return 0;
  15. }

Problem Description

求实数的绝对值。

Input

输入数据有多组,每组占一行,每行包含一个实数。

Output

对于每组输入数据,输出它的绝对值,要求每组数据输出一行,结果保留两位小数。

Sample Input

123

-234.00

Sample Output

123.00

234.00

字面意思,算绝对值

  1. #include <iostream>
  2. #include <cstdio>
  3. #include <cmath>
  4. #include <cstring>
  5. #include <algorithm>
  6. using namespace std;
  7. double n, m;
  8. int main() {
  9. while (scanf("%lf", &n) != EOF) {
  10. m = abs(n);
  11. printf("%.2lf\n", m);
  12. }
  13. return 0;
  14. }

Problem Description

输入一个百分制的成绩t,将其转换成对应的等级,具体转换规则如下:

90~100为A;

80~89为B;

70~79为C;

60~69为D;

0~59为E;

Input

输入数据有多组,每组占一行,由一个整数组成。

Output

对于每组输入数据,输出一行。如果输入数据不在0~100范围内,请输出一行:“Score is error!”。

Sample Input

56

67

100

123

Sample Output

E

D

A

Score is error!

很简单的判断问题

  1. #include <iostream>
  2. #include <cstdio>
  3. #include <cmath>
  4. #include <cstring>
  5. #include <algorithm>
  6. using namespace std;
  7. int n;
  8. int main() {
  9. while (scanf("%d", &n) != EOF) {
  10. if (n >= 90 && n <= 100) cout << "A" << endl;
  11. else if (n >= 80 && n <= 89) cout << "B" << endl;
  12. else if (n >= 70 && n <= 79) cout << "C" <<endl;
  13. else if (n >= 60 && n <= 69) cout << "D" << endl;
  14. else if (n >= 0 && n <= 59) cout << "E" << endl;
  15. else cout << "Score is error!" << endl;
  16. }
  17. return 0;
  18. }

Problem Description

给定一个日期,输出这个日期是该年的第几天。

Input

输入数据有多组,每组占一行,数据格式为YYYY/MM/DD组成,具体参见sample input ,另外,可以向你确保所有的输入数据是合法的。

Output

对于每组输入数据,输出一行,表示该日期是该年的第几天。

Sample Input

1985/1/20

2006/3/12

Sample Output

20

71

要判断这一年是不是闰年,由于鄙人贫乏的生活常识,还百度了一下什么是闰年......

需要两个数组,一个储存闰年每月的天数,一个储存平年每月的天数

  1. #include <iostream>
  2. #include <cstdio>
  3. #include <cmath>
  4. #include <cstring>
  5. #include <algorithm>
  6. using namespace std;
  7. int x, y, z;
  8. int day1[13] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  9. int day2[13] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  10. bool check(int year) {
  11. if ((year % 4 ==0 && year % 100 != 0) || year % 400 == 0) return true;
  12. return false;
  13. }
  14. int main() {
  15. while (scanf("%d/%d/%d", &x, &y, &z) != EOF) {
  16. int ans = 0;
  17. if (check(x)) {
  18. for (int i = 0; i < y - 1; i++) ans += day1[i];
  19. ans += z;
  20. printf("%d\n", ans);
  21. } else {
  22. for (int i = 0; i < y - 1; i++) ans += day2[i];
  23. ans += z;
  24. printf("%d\n", ans);
  25. }
  26. }
  27. return 0;
  28. }

Problem Description

给你n个整数,求他们中所有奇数的乘积。

Input

输入数据包含多个测试实例,每个测试实例占一行,每行的第一个数为n,表示本组数据一共有n个,接着是n个整数,你可以假设每组数据必定至少存在一个奇数。

Output

输出每组数中的所有奇数的乘积,对于测试实例,输出一行。

Sample Input

3 1 2 3

4 2 3 4 5

Sample Output

3

15

就是把是奇数的数都乘起来呗

  1. #include <iostream>
  2. #include <cstdio>
  3. #include <cmath>
  4. #include <cstring>
  5. #include <algorithm>
  6. using namespace std;
  7. int n, m;
  8. int main() {
  9. while (scanf("%d", &n) != EOF) {
  10. int ans = 1;
  11. while (n--) {
  12. scanf("%d", &m);
  13. if (m % 2 == 1) ans *= m;
  14. }
  15. printf("%d\n", ans);
  16. }
  17. return 0;
  18. }

Problem Description

给定一段连续的整数,求出他们中所有偶数的平方和以及所有奇数的立方和。

Input

输入数据包含多组测试实例,每组测试实例包含一行,由两个整数m和n组成。

Output

对于每组输入数据,输出一行,应包括两个整数x和y,分别表示该段连续的整数中所有偶数的平方和以及所有奇数的立方和。

你可以认为32位整数足以保存结果。

Sample Input

1 3

2 5

Sample Output

4 28

20 152

把区间内的偶数平方,把奇数立方,分别加吧起来

  1. #include <iostream>
  2. #include <cstdio>
  3. #include <cmath>
  4. #include <cstring>
  5. #include <algorithm>
  6. using namespace std;
  7. int n, m;
  8. long long ans1, ans2;
  9. int main() {
  10. while (scanf("%d%d", &n, &m) != EOF) {
  11. ans1 = 0;
  12. ans2 = 0;
  13. if (n > m) {
  14. int x = n;
  15. n = m;
  16. m = x;
  17. }
  18. for (int i = n; i <= m; i++) {
  19. if (i % 2 == 0) ans1 += i * i;
  20. else ans2 += i * i * i;
  21. }
  22. printf("%lld %lld\n", ans1, ans2);
  23. }
  24. return 0;
  25. }

Problem Description

统计给定的n个数中,负数、零和正数的个数。

Input

输入数据有多组,每组占一行,每行的第一个数是整数n(n<100),表示需要统计的数值的个数,然后是n个实数;如果n=0,则表示输入结束,该行不做处理。

Output

对于每组输入数据,输出一行a,b和c,分别表示给定的数据中负数、零和正数的个数。

Sample Input

6 0 1 2 3 -1 0

5 1 2 3 4 0.5

0

Sample Output

1 2 3

0 0 5

呃,就是分类统计一下

  1. #include <iostream>
  2. #include <cstdio>
  3. #include <cmath>
  4. #include <cstring>
  5. #include <algorithm>
  6. using namespace std;
  7. int n, ans1, ans2, ans3;
  8. double m;
  9. int main() {
  10. while (scanf("%d", &n) != EOF) {
  11. if (n == 0) break;
  12. ans1 = ans2 = ans3 = 0;
  13. while (n--) {
  14. scanf("%lf", &m);
  15. if (m > 0.0) ans3++;
  16. else if (m < 0.0) ans1++;
  17. else ans2++;
  18. }
  19. printf("%d %d %d\n", ans1, ans2, ans3);
  20. }
  21. return 0;
  22. }

Problem Description

数列的定义如下:

数列的第一项为n,以后各项为前一项的平方根,求数列的前m项的和。

Input

输入数据有多组,每组占一行,由两个整数n(n<10000)和m(m<1000)组成,n和m的含义如前所述。

Output

对于每组输入数据,输出该数列的和,每个测试实例占一行,要求精度保留2位小数。

Sample Input

81 4

2 2

Sample Output

94.73

3.41

高中数学,数列求和

  1. #include <iostream>
  2. #include <cstdio>
  3. #include <cmath>
  4. #include <cstring>
  5. #include <algorithm>
  6. using namespace std;
  7. double n, m, ans;
  8. int main() {
  9. while (scanf("%lf%lf", &n, &m) != EOF) {
  10. m--;
  11. ans = n;
  12. while (m--) {
  13. ans += sqrt(n);
  14. n = sqrt(n);
  15. }
  16. printf("%.2lf\n", ans);
  17. }
  18. return 0;
  19. }

HDU100题简要题解(2000~2009)的更多相关文章

  1. HDU100题简要题解(2060~2069)

    这十题感觉是100题内相对较为麻烦的,有点搞我心态... HDU2060 Snooker 题目链接 Problem Description background: Philip likes to pl ...

  2. HDU100题简要题解(2080~2089)

    //2089之前忘做了,周二C语言课上做,至于2086,写题解的时候突然发现之前的做法是错的,新的解法交上去CE,等周二再弄吧,其余题目暂时可以放心 HDU2080 夹角有多大II 题目链接 Prob ...

  3. HDU100题简要题解(2070~2079)

    HDU2070 Fibbonacci Number 题目链接 Problem Description Your objective for this question is to develop a ...

  4. HDU100题简要题解(2050~2059)

    HDU2050 折线分割平面 题目链接 Problem Description 我们看到过很多直线分割平面的题目,今天的这个题目稍微有些变化,我们要求的是n条折线分割平面的最大数目.比如,一条折线可以 ...

  5. HDU100题简要题解(2040~2049)

    HDU2040 亲和数 题目链接 Problem Description 古希腊数学家毕达哥拉斯在自然数研究中发现,220的所有真约数(即不是自身的约数)之和为: 1+2+4+5+10+11+20+2 ...

  6. HDU100题简要题解(2030~2039)

    HDU2030 汉字统计 题目链接 Problem Description 统计给定文本文件中汉字的个数. Input 输入文件首先包含一个整数n,表示测试实例的个数,然后是n段文本. Output ...

  7. HDU100题简要题解(2020~2029)

    HDU2020 绝对值排序 题目链接 Problem Description 输入n(n<=100)个整数,按照绝对值从大到小排序后输出.题目保证对于每一个测试实例,所有的数的绝对值都不相等. ...

  8. HDU100题简要题解(2010~2019)

    HDU2010 水仙花数 题目链接 Problem Description 春天是鲜花的季节,水仙花就是其中最迷人的代表,数学上有个水仙花数,他是这样定义的: "水仙花数"是指一个 ...

  9. 【HNOI2019】部分题简要题解

    题意懒得写了 LOJ Day 1 T1 鱼 个人做法比较猎奇,如果有哪位大佬会证明能分享一下的话感激不尽. 题解:枚举鱼尾和鱼身的交点D,将所有其他点按照到D的距离排序,距离相同的分一组. 感性的理解 ...

随机推荐

  1. 深入理解Java的抽象类和接口

    对于面向对象来说,抽象是其重要特征之一.对于之中的抽象类和接口,两者有很多相似的地方,又有两者之间区别的地方. 用几个简单的例子让你快速的理解两者之间的概念和区别 鸣谢 一.抽象类 在了解抽象类之前, ...

  2. CDH+Kylin三部曲之一:准备工作

    欢迎访问我的GitHub https://github.com/zq2599/blog_demos 内容:所有原创文章分类汇总及配套源码,涉及Java.Docker.Kubernetes.DevOPS ...

  3. git添加空文件夹

    最近刚接触git这个工具,发现git是不能提交空文件的:找了下资料,找到了解决提交文件夹的办法,现在记录一下. git是不允许提交一个空的目录到版本库上的,可以在空文件夹下面添加.gitkeep文件, ...

  4. Luogu P5072 [Ynoi2015]盼君勿忘

    题意 给定一个长度为 \(n\) 的序列 \(a\) 和 \(m\) 次询问,第 \(i\) 次询问需要求出 \([l_i,r_i]\) 内所有子序列去重之后的和,对 \(p_i\) 取模. \(\t ...

  5. Java学习的第二十四天

    1. 目录管理 2.文件方法太多记不清 3.明天学习流和流的分类

  6. Amdocs收购OPENET:关于5G应用落地的思考

    今年8月,全球通讯和媒体领导者之一Amdocs收购了Openet.在VoltDB,听到这个消息,我们感到非常高兴和自豪!在过去的7年里,我们一直是Openet解决方案的基础数据平台. 尽管许多供应商仍 ...

  7. 团灭 LeetCode 股票买卖问题

    很多读者抱怨 LeetCode 的股票系列问题奇技淫巧太多,如果面试真的遇到这类问题,基本不会想到那些巧妙的办法,怎么办?所以本文拒绝奇技淫巧,而是稳扎稳打,只用一种通用方法解决所用问题,以不变应万变 ...

  8. NOI2020D1T1美食家

    传送门:QAQQAQ 完了完了NOI签到题全班打不出来,真就全部成为时代的眼泪了... 首先$O(mT)$的$dp$显然,然后因为$T$很大$w$很小矩阵快速幂显然,但是有$k=200$卡不过去. 然 ...

  9. 选择API管理平台之前要考虑的5个因素

    API(应用程序编程接口)经济的飞速增长导致对API管理平台的需求相应增加. 这些解决方案可在整个生命周期内帮助创建,实施,监控,分析,保护和管理API. 据一些估计,全球API管理市场预计在2018 ...

  10. c++ 从vector扩容看noexcept应用场景

    c++11提供了关键字noexcept,用来指明某个函数无法--或不打算--抛出异常: void foo() noexcept; // a function specified as will nev ...