
HDU
liuxiaocs7
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
HDU1000
最开始基础的A + B problem关键在于Process to end of file 就是处理到文件的结束此处为坑#include <iostream>using namespace std;int main(){ int a; int b; while(cin>>a>>b) { cout<<(a+b)<<...原创 2018-08-01 20:21:49 · 207 阅读 · 0 评论 -
HDU2012 素数判定
#include <iostream>#include <cstdio>#include <cmath>using namespace std;bool IsPrime(int x){ int len = (int)sqrt(x); for(int i=2; i<=len; i++) { if(x%i == 0) retu...原创 2018-10-13 15:10:01 · 267 阅读 · 0 评论 -
HDU2013 蟠桃记
迭代#include <iostream>using namespace std;int main(){ int n; while(cin >> n) { int today = 1; int yesterday = 0; for(int i=1; i<n; i++) { yesterday = (today+1)*2; ...原创 2018-10-13 15:29:57 · 257 阅读 · 0 评论 -
HDU1013 Digital Roots
输入结束条件为0;原创 2018-10-08 23:55:04 · 251 阅读 · 0 评论 -
HDU2014 青年歌手大赛_评委会打分
#include <iostream>#include <cstdio>using namespace std;int main(){ int n; while(cin >> n) { int sum = 0; int a; cin >> a; int max = a; int min = a; sum +...原创 2018-10-14 19:44:53 · 305 阅读 · 0 评论 -
HDU2015 偶数求和
#include <iostream>using namespace std;int main(){ int n, m; while(cin >> n >> m) { int sum = 0; int a[n+1] = {0}; bool flag = true; for(int i=1; i<=n; i++) {...原创 2018-10-15 19:48:01 · 278 阅读 · 0 评论 -
HDU1017 A Mathematical Curiosity
输入结束条件为n = m = 0输入格式很重要先输入的整数代表输入块结果是计算每一个块中的每一组测试用例的结果。整体思路是二重循环遍历所有情况 –判断一个数是否为整数bool isInt(double x){ long int y=(long int) x; //if ((x-y)!=0)//这段代码可能会丢失精度 if((x-y)<=0.00000...原创 2018-10-09 21:52:54 · 237 阅读 · 0 评论 -
HDU2016 数据的交换输出
#include <iostream>#include <algorithm>using namespace std;int main(){ int n; while(cin >> n && n!=0) { int a[n]; for(int i=0; i<n; i++) { cin >> ...原创 2018-10-16 20:44:52 · 196 阅读 · 0 评论 -
HDU2017 字符串统计
#include <iostream>#include <algorithm>using namespace std;int main(){ int n; cin >> n; while(n--) { string s; cin >> s; int len = s.size(); int sum = 0; f...原创 2018-10-16 21:24:36 · 352 阅读 · 0 评论 -
HDU2018 母牛的故事
类似于斐波那契数列。递推式:f(n) = n (n<=4)f(n) = f(n-1) + f(n-3) (n>4)递归解决:#include <iostream>using namespace std;int sum(int n){ if(n<=4) { return n; } else { return sum(n-1)+...原创 2018-10-16 21:51:06 · 195 阅读 · 0 评论 -
HDU2019 数列有序
原创 2018-10-17 20:38:51 · 171 阅读 · 0 评论 -
HDU2020 绝对值排序
#include <iostream>#include <cstdio>#include <cmath>using namespace std;int main(){ int n; while(cin >> n && n!=0) { //int a[n]; int *a = new int[n]; f...原创 2018-10-22 19:22:23 · 285 阅读 · 0 评论 -
HDU 2021 发工资了
多个测试用例#include <iostream>using namespace std;int main(){ int n; // 老师数 int sum = 0; // 总计钞票的数量 int m; int x; // 每个老师的钱 int a[6] = {100, 50, 10, 5, 2, 1}; //存放币值 while(true) {...原创 2019-02-19 17:15:02 · 187 阅读 · 0 评论 -
HDU2022 海选女主角
一开始将输入的数据存入数组中,一直爆掉#include <iostream>#include <cmath>using namespace std;int main(){ int m, n; while(true) { cin >> m>> n; long **s = new long* [m]; for(int i=0...原创 2019-02-19 18:02:50 · 393 阅读 · 0 评论 -
HDU2024 C语言合法标识符
原创 2019-02-20 23:50:44 · 386 阅读 · 0 评论 -
HDU2011 多项式求和
#include <iostream>#include <cstdio>using namespace std;int main(){ int m; cin >> m; while(m--) { int n; cin >> n; double sum = 0.0; for(int i=1; i<=n; i...原创 2018-10-13 14:48:38 · 189 阅读 · 0 评论 -
HDU 2010 水仙花数
#include <iostream>using namespace std;bool IsFlower(int n){ int sum = 0; int m = n; while(n) { sum += (n%10)*(n%10)*(n%10); n /= 10; } if(sum == m) { return true; } else ...原创 2018-10-13 14:18:54 · 193 阅读 · 0 评论 -
HDU2009 求数列的和
#include <iostream>#include <cmath>#include <cstdio>using namespace std;int main(){ double n; int m; while(cin >> n >> m) { double sum = 0; while(m--) ...原创 2018-10-13 13:58:03 · 245 阅读 · 0 评论 -
HDU1001
#include <iostream>using namespace std;int main(){ int a; while(cin>>a) { int sum = 0; for(int i=1; i<=a; i++) sum += i; cout<<sum<<endl<<endl; }...原创 2018-08-01 20:52:17 · 854 阅读 · 0 评论 -
HDU1005 Number Sequence
#include <iostream>using namespace std;int a, b;int process(int n);int main(){ int n; while(1) { cin>>a>>b>>n; if(a==0 && b ==0 && n==0)...原创 2018-08-01 21:41:20 · 155 阅读 · 0 评论 -
HDU1019 Least Common Multiple
思路:外层循环控制问题数,内层读入输入计算最小公倍数求最小公倍数=两数的乘积/最大公约数错误。。。#include &lt;iostream&gt;using namespace std;int LeastNum(int a, int b){ int c = 0; int m = a; //保存a,b的值 int n = b; while(b != 0) { c =...原创 2018-10-11 21:30:41 · 256 阅读 · 0 评论 -
HDU1021 Fibonacci Again
斐波那契数列的变形而已。#include &lt;iostream&gt;using namespace std;int Fbi(int n){ if(n == 0) { return 11; } else if(n == 1) { return 7; } else { return Fbi(n-1) + Fbi(n-2); }}int main...原创 2018-10-11 23:25:20 · 317 阅读 · 0 评论 -
HDU1008
思路读入总共的层数(确保层数不为0,否则直接退出循环)层数为接下来循环的次数,每次读入楼层,注意每一次读入新的楼层数,意味着在该楼层都要停留5秒钟,即time += 5;为必要操作接下来判断读入楼层与当前楼层之间的关系,分别对应上楼和下楼两种情况,循环即将结束时,更新当前楼层。输出时间即处理完一次。。。#include &lt;iostream&gt;using namesp...原创 2018-10-05 11:33:50 · 332 阅读 · 0 评论 -
HDU1012 u Calculate e
AC代码思路主要是注意输出的格式问题,以及求e时连续的九项输出,可以边累加边输出,不必要每次计算载输出。#include <iostream>#include <cstdio>using namespace std;int factorial(int n);int main(){ cout<< "n " << "e"...原创 2018-10-05 12:17:57 · 294 阅读 · 0 评论 -
HDU2000 ASC码排序
#include <iostream>using namespace std;char s[] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p','q','r', 's','t','u','v','w','x','y','z'};int main()...原创 2018-10-12 20:01:18 · 201 阅读 · 0 评论 -
HDU2001计算两点间距离
直接AC#include <iostream>#include <cstdio>#include <cmath>using namespace std;int main(){ double x1, y1, x2, y2; while(cin >> x1 >> y1 >> x2 >> y2) {原创 2018-10-12 20:07:46 · 198 阅读 · 0 评论 -
HDU2002 计算球体积
#include <iostream>#include <cstdio>#define PI 3.1415927using namespace std;int main(){ double r; while(cin >> r) { double V = 4*PI*r*r*r/3; printf("%.3f\n", V); } ...原创 2018-10-12 20:13:44 · 192 阅读 · 0 评论 -
HDU2003 求绝对值
#include <iostream>#include <cstdio>#include <cmath>using namespace std;int main(){ double r; while(cin >> r) { printf("%.2f\n", abs(r)); } return 0;}原创 2018-10-12 20:17:32 · 212 阅读 · 0 评论 -
HDU2004 成绩转换
#include <iostream>#include <cstdio>#include <cmath>using namespace std;int main(){ int score; while(cin >> score) { if(score<0 || score>100) { cout <...原创 2018-10-12 20:25:03 · 235 阅读 · 0 评论 -
HDU2005 第几天
#include <iostream>#include <cstdio>#include <cmath>bool IsLeapYear(int year){ return ((year%4==0&&year%100!=0) || year%400==0);}using namespace std;int main(){...原创 2018-10-12 20:36:33 · 379 阅读 · 0 评论 -
HDU2006 求奇数的乘积
#include <iostream>using namespace std;int main(){ int n; while(cin >> n) { int result = 1; while(n--) { int x; cin >> x; if(x % 2 == 1) { result *= x;...原创 2018-10-12 20:43:14 · 155 阅读 · 0 评论 -
HDU2007 平方和和立方和
输入数据没有判断x和y的大小。。。#include <iostream>using namespace std;int main(){ int x, y; while(cin >>x >> y) { int sum1 = 0; int sum2 = 0; for(int i=x; i<=y; i++) { if(i...原创 2018-10-12 20:53:14 · 230 阅读 · 0 评论 -
HDU2008 数值统计
#include <iostream>using namespace std;int main(){ int n; while(cin >> n && n!=0) { int n1 = 0; int n2 = 0; int n3 = 0; while(n--) { double x; cin >>...原创 2018-10-12 20:59:03 · 183 阅读 · 0 评论 -
HDU2023 求平均成绩
原创 2019-02-20 23:51:14 · 316 阅读 · 0 评论