![](https://img-blog.csdnimg.cn/20201014180756922.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
HDU
hdu题解
qq_45693271
这个作者很懒,什么都没留下…
展开
-
hdu 1215 七夕节
此代码会超时#include<iostream>using namespace std;int main(){ int t, n, i; int sum = 0; cin >> t; while(t--) { int sum = 0; cin >> n; for(i=1; i<=n/2; i++) { if(n % i ==0) sum+=i; } cout << sum << ..原创 2021-04-30 17:16:33 · 74 阅读 · 1 评论 -
hdu1425 sort
代码一:#include<iostream>#include<algorithm>#include<cstdio>using namespace std;int a[1000000];int cmp(int a, int b){ return a > b;}int main(){ int n,m,i; while(~scanf("%d%d",&n,&m)) { for(i=0; i<n; i++) sca.原创 2021-05-06 09:45:29 · 61 阅读 · 0 评论 -
hdu1418 抱歉
欧拉公式:点数 + 面数 - 线数 = 2#include<iostream>using namespace std;int main(){ unsigned int n,m; while(cin>>n>>m&&(n||m)) cout<<n+m-2<<endl;}原创 2021-05-05 20:09:22 · 69 阅读 · 0 评论 -
hdu1071 The area
#include<stdio.h>#include<math.h>struct point{ double x,y;};//注意结构体的使用int main(){ double a,m,c,k,b,area,f; struct point p[4]; int i,t; scanf("%d",&t); while(t--) { for(i=1;i<=3;i++) sc..原创 2021-04-24 14:28:33 · 85 阅读 · 0 评论 -
hdu1021 Fibonacci Again
通过找规律可以得到最终的结果#include<stdio.h>#include<iostream>using namespace std;int main(){ //7 11 18 29 47 76 123 199 322 521 843 1346 2207 3353 5760 //由此可以看出当 n % 4 == 2 时所代表的数可以被三整除 int n; while(cin >> n) { if(n % 4 == 2) cout &.原创 2021-04-23 20:27:06 · 59 阅读 · 0 评论 -
hdu 2001 计算两点间的距离
#include<stdio.h>#include<string>#include<iostream>#include<algorithm>#include<math.h>using namespace std;int main(){ double a, b, c, d; double m, n, f; while(cin >> a >> b >> c >>d) { m =.原创 2021-04-23 19:30:24 · 38 阅读 · 0 评论 -
hdu 2000 ASCII码排序
此题在c++中较为简单,一个sort函数就可以搞定,但是还是要注意下输出的格式#include<stdio.h>#include<string>#include<iostream>#include<algorithm>using namespace std;int main(){ //char s[3]; string s; int i; while(cin >> s) { sort(s.begin(), s.end(.原创 2021-04-20 19:42:05 · 45 阅读 · 0 评论 -
1005 Number Sequence
利用鸽巢原理可知共有49种可能即(f[i-1],f[i-2]分别都可能为0,1,2,3,4,5,6)且f[n]为一循环的数字,找到规律即可,此代码在hdu上无法通过,错误未知。#include <stdio.h>#include <iostream>#include <algorithm>using namespace std;int f[100];int main(){ int a, b, i, n; int pos = 0; while(1).原创 2021-04-08 17:06:49 · 56 阅读 · 0 评论 -
hdu 2629 Identity Card
代码如下(正确代码)#include <iostream>#include <string>using namespace std;int main(){ int n, t; string a, area; cin >> n; while(n--) { cin >> a; t = (a[0]-'0')*10+a[1]-'0'; switch(t) { case 11: area = "Beijing";break;原创 2021-01-29 22:35:17 · 1690 阅读 · 0 评论 -
hdu1328 IBM Minus One
此题较简单,没多大的难度#include <stdio.h>#include <string.h>int main(){ char a[50]; int i, n, m; scanf("%d", &n); m = 1; while (n--) { printf("String #%d\n", m); scanf("%s", a); int l=strlen(a); for(i = 0; i < l; i++) { .原创 2021-01-26 16:48:02 · 115 阅读 · 0 评论 -
hdu 2393 Higher Math
此题较简单,没有什么难点废话不多说,上代码#include<iostream>#include<stdio.h>using namespace std;int main(){ int n,d; scanf_s("%d\n", &n); d = 1; while (n--) { int a, b, c; scanf_s("%d %d %d", &a, &b, &c); if ((a * a + b * b == c * .原创 2021-01-19 16:55:53 · 77 阅读 · 0 评论 -
hdu 1326 Box of Bricks
此题不是太复杂,通过题目中的But since Bob is lazy he wants to do this with the minimum number of bricks moved.这一句话可知要求的移动的的砖块最少既是让我们尽可能少的移动砖块。首先是通过while循环以保证在输入0之前程序可以一直不停的执行。而while循环中的n则是表示这一堵墙共有多少列,在while循环中在通过for循环输入n个数,存入数组a[i],这n个数则表示初始时这一堵墙每一列的砖的数目。然后通过:砖的总数/列.原创 2020-11-18 15:06:54 · 133 阅读 · 0 评论 -
hdu 1720 A+B Coming
此题在hdu中算是比较简单的基础题了,解题方法比较多,你可以像我直这样以%d的形式直接输出算是一种比较简单且快捷的方法#include <stdio.h>int main(){ int a, b; while (scanf_s("%x %x", &a, &b) != EOF) printf("%d\n", a + b); return 0;}当然你还可以通过直接用#define来直接定义A=a=11;B=b=12…你还可以通过switch语句,if语.原创 2020-11-15 09:28:39 · 143 阅读 · 0 评论 -
hdu 1064 Financial Management
此题在hdu中属于基础题,题目比较简单,但同时还是有几点需要注意。首先是题目中的隐藏条件。即精确到分,换句话说意思就是数据都保留两位小数。其次就是在最后输出时需要换行以及别忘了加上美元符号($)。代码如下:#include <iostream>#include <stdio.h>#include <math.h>using namespace std;int main(){ int i; double sum, a; sum = 0.0; for ..原创 2020-11-14 19:59:54 · 111 阅读 · 0 评论 -
1017 A Mathematical Curiosity
本道题咋一看,或许不知道从何下手,但再仔细认真读下题目便会豁然开朗。题目的意思是说输入两个数n,m。计算式子(aa+bb +m)/(a*b)(其中0 < a < b < n,也就是说,a,b可以是满足0 < a < b < n下的任意值)判断有几对m,n可以使式子的计算结果为整数。当然题目不可能这么简单,为了增加难度,题目还有一个条件需要满足,也就需要进行多组运算,并且每一组又要进行多次计算,并且以m=n=0结束每一组的运算。(执行一次最外围的while循环为一组,..原创 2020-11-10 16:58:58 · 70 阅读 · 0 评论 -
1018 Big Number
1018 Big Number对于此题,题目不难理解,第一反应应该都是递归吧,按理说是可以通过的递归来实现的,但是。。。。。#include <iostream>#include <stdio.h>#include <math.h>using namespace std;int factorial(int n){ if (n == 0) return 1; else return n * factorial(n - 1);}int main原创 2020-11-08 22:58:24 · 59 阅读 · 0 评论 -
2104 hide handkerchief
hide handkerchief 此题的关键在于如何将题目转化为我们我们熟悉的的样式,即两个数是否互质(保证两个数的最大公因数为1即可)。如以N=4 M=2为例,根据题意Haha找的箱子始终为1号和3号箱,始终都不会找为他两公因数的2号和4号箱代码如下:#include <iostream>using namespace std;//方法一/*int gongmax(int N, int M){ int i; for (i = 2; i <= M; i++) {原创 2020-11-07 15:52:48 · 85 阅读 · 0 评论