自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(38)
  • 收藏
  • 关注

原创 HDU1230 火星A+B【进制】

#include <stdio.h>#include <memory.h>#define MAXN 30int primes[26]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101};int a[MAXN],b[MAXN],sum[MAXN],acount,...

2019-03-05 20:08:07 174

转载 HDU1234 开门人和关门人[入门+时间比较]

大佬的想法真是妙/* HDU1234 开门人和关门人 */ #include <iostream>#include <algorithm>#include <cstdio> using namespace std; struct node{ char name[20]; int starttime; int endti...

2019-02-28 16:52:09 195

原创 HDU2022 海选女主角[入门]

#include <iostream>#include <stdlib.h>using namespace std;int main(){ int m,n,max,h,l,i,j,val; while(cin>>m>>n){ max=0; h=1; l=1; //数据读入并实时更新最大值 for(i=1;...

2019-02-28 16:04:01 273

转载 HDU2019 数列有序![入门]

/* HDU2019 数列有序! */ #include <stdio.h> int main(void){ int n, m, val, i; while(scanf("%d%d", &n, &m) != EOF) { if(n == 0 && m == 0) break; ...

2019-02-27 22:22:53 938

原创 HDU2014 青年歌手大奖赛_评委会打分[入门]

#include <stdio.h>#include <iostream>using namespace std; int main(void){ int n; while(cin>>n) { // 定义变量并且初始化 int score, sum=0, max=0, min=101, i; ...

2019-02-27 21:59:27 381

原创 HDU2503 a/b + c/d[入门+辗转相除]

辗转相除求最大公约数!/* HDU2503 a/b + c/d */ #include <iostream> using namespace std; // 非递归计算最大公约数int gcd(int m, int n){ for(;;) { if(n == 0) return m; int temp ...

2019-02-26 21:34:10 223

原创 HDU1406 完数[入门+筛选法]

还是先打表,和HDU1215一样。/* HDU1406 完数 */ #include <iostream>#include <cstring> using namespace std; const int MAXN = 10000; int sum[MAXN+1]; void maketable(int n){ memset(sum, 0...

2019-02-26 21:14:28 151

转载 HDU1215 七夕节[入门+筛选法+打表]

#include <iostream>#include <cstring> using namespace std; const int MAXN = 500000; int sum[MAXN+1]; void maketable(int n){ memset(sum, 0, sizeof(sum)); sum[1] = 0; ...

2019-02-26 21:05:50 147

原创 HDU1279 验证角谷猜想[入门]

只输出过程中的奇数/* HDU1279 验证角谷猜想 */ #include <iostream> using namespace std; int main(){ int n, m, count; cin >> n; while(n--) { cin >> m; count = ...

2019-02-26 17:54:44 367

原创 HDU1229 还是A+B[入门]

用10的K次幂求出末尾k位。 #include <iostream>#include <cmath> using namespace std;int main(){ int a, b, k, temp; while(cin>>a>>b>>k) { if(a == 0 &&...

2019-02-26 16:34:07 118

原创 HDU1273 漫步森林[入门]

n个结点,各个结点间都是想通的,所以有(n-1)*n/2条边。每走一次都需要(也只需)n条边才能经过n个顶点,所以答案是(n-1)/2,即((n-1)*n/2)/n=(n-1)/2。/* HDU1273 漫步森林 */ #include <iostream> using namespace std; int main(){ int n; while...

2019-02-26 11:41:29 196

原创 HDU1996 汉诺塔VI[入门]

本题实际上是计算3^n。编程中需要注意输出格式。???为森么?数学问题搞不清楚辽······注意输出格式#include <iostream>#include <cmath>using namespace std;int main(){ int t,n; cin>>t; while(t--){ cin>>n; ...

2019-02-26 11:29:34 190

原创 HDU1201 18岁生日[入门+]

使用scanf()标准化输入非常方便。#include <iostream>#include <cstdio>using namespace std;const int N =18;const int Yeardays =365;//闰年计算函数int leapyear(int year){ if((year%4==0&&year&a...

2019-02-26 11:05:12 732

原创 HDU1412 {A} + {B}[入门+]

insert 的时候已经排序了。set的数据结构是红黑树。#include <iostream>#include <set>using namespace std;int main(){ int n,m,val; set<int> result; while(cin>>n>>m){ result.clear()...

2019-02-25 17:42:15 150

原创 HDU2034 人见人爱A-B[入门+]

#include <iostream>#include <set>using namespace std;int main(){ int n,m,val; set<int> result; while(cin>>n>>m){ if(n==0 && m==0) break; resu...

2019-02-25 16:41:20 197

原创 HDU2072 单词数[入门]

程序中使用set、(字符串流)中的istringstream以及string。/* HDU2072 单词数 */ #include <iostream>#include <cstdio>#include <sstream>#include <set> using namespace std; int main()

2019-02-25 11:09:22 219

原创 HDU1282 回文数猜想[入门+]

using namespace std;#include <iostream>bool isPalindrome(int n,int &t){ int temp1=n; t=0; while(n>0){ t=t*10+n%10; n/=10; } return temp1==t;}int main(){ int a,v[100],...

2019-02-25 10:46:22 217

原创 HDU2021 发工资咯:)[入门]

using namespace std;#include <iostream> int main(void){ int bill[] = {100, 50, 10, 5, 2, 1}; int billcount = sizeof(bill) / sizeof(int); int n, count, val, i, j; while(cin...

2019-02-25 07:52:50 180

原创 HDU2024 C语言合法标识符[入门]

/* HDU2024 C语言合法标识符 */ #include <stdio.h>#include <ctype.h> #include<stdlib.h> int main(void){ int n; char s[50+1], *t; gets(s); n = atoi(s);//在stdlib头文件里 ...

2019-02-25 07:33:25 276

原创 HDU2016 数据的交换输出[入门]

应该输入的时候就判断最小值了吧,不过懒得改了,以后再看的时候,再回来改一下。#include <stdio.h> int main(void){ int n, val[100+1], mini, i; while(scanf("%d", &n) != EOF) { // 结束判断 if(n==0) ...

2019-02-23 17:10:06 230

原创 HDU2015 偶数求和[入门]

程序的关键有以下几点:1.使用模除 模除运算在C语言中用取余运算符%来实现。2.循环控制 包括两个循环。3.输出控制 各项间有间隔空格,行最后没有空格。using namespace std;#include <iostream>int main(){ int n,m; while(cin>>n>>m){ int sum=0,ai=2...

2019-02-23 16:47:12 383

原创 HDU2012 素数判定[入门]

#include <stdio.h>#include <math.h> #define fun(n) n*n + n + 41 // 试除法判断一个整数是否为素数int isnotprime(int n){ if(n % 2 == 0) return 1; int end = sqrt(n), i; for(i=3...

2019-02-23 16:10:17 326

原创 HDU2011 多项式求和[入门]

using namespace std;#include<iostream> #include<math.h>int main(){ int m,n,i; double sum; cin>>m; while(m--){ //写n cin>>n; sum=0.0; //计算 for(i=1;i&lt...

2019-02-23 14:45:23 174

原创 HDU2009 求数列的和[入门]

printf("%.2f\n",sum);//保留两位小数using namespace std;#include<iostream> #include<math.h>int main(){ int n,m; double sum,sq; while(cin>>n>>m){ sum=n; sq=n; //数列求...

2019-02-23 12:35:06 169

原创 HDU2007 平方和与立方和[入门]

与运算,两个数同时为1的时候才为1,你可以随便取一个奇数,转成二进制最后一位肯定是1比如:11 转成二进制1 0 1 1& 0 0 0 10 0 0 1所以,奇数与1作与运算,结果肯定是1using namespace std;#include <iostream>int main (){ int m,n,even_sum,odd_sum,i; wh...

2019-02-17 20:53:10 180

原创 HDU2017 字符串统计[入门]

using namespace std;#include <iostream>#include <ctype.h> //isdigit() #define MAXSIZE 4096 int main(void){ int n, count; char s[MAXSIZE], *t; scanf("%d", &n); ...

2019-02-17 17:38:27 210

原创 HDU2025 查找最大元素[入门]

//用指针解决 using namespace std;#include <iostream>int main (){ char s[100+1],max,*t; while(cin>>s){ max='\0'; //每次初始化max //search for max t=s; while(*t){ if(*t>max)...

2019-02-17 16:24:34 132

原创 HDU2099 整除的尾数[入门]

//枚举法#include <iostream> using namespace std; const int MOD = 100; int main(){ int a, b, count; while(cin >> a >> b) { if(a == 0 && b == 0)//判断结束 ...

2019-02-17 15:18:55 143

原创 HDU2097 Sky数[入门]

using namespace std;#include <iostream>int digitsum(int val,int base){ int sum=0; while(val){ sum+=val%base; val/=base; } return sum;} int main(){ int n,sum ,skyflag,i; int scal...

2019-02-15 22:21:20 150

原创 HDU1287 破译密码[入门]

using namespace std;#include <iostream>#include <ctype.h>int main(){ int n,v[1024],x,i,j; while(cin>>n){ //输入数据 用cin超时??? //for(i=0;j<n;i++) // cin>>v[i]; ...

2019-02-15 19:45:19 179

原创 HDU4548 美素数[入门]

using namespace std;#include <iostream>#include <cmath> #define MAXN 1000000 int ans[MAXN+2] = {0, 0, 1}; // ans[i] 为0到i的美素数个数 //筛选法判断素数 int isprime(int n){ if (n==3||n==2) ...

2019-02-15 17:09:30 363

原创 HDU2041 超级楼梯[入门]

由于每次只能上一级或两级,那么f(n)=f(n-2)+f(n-1)——一个菲波拉契数列。开始时候是站在第1级台阶上,所以数列的开始几项会有所不同。f(1)=0,因为开始就站在第1级台阶上;f(2)=1,只能从第1级台阶上1级;f(3)=2,只能从第1级台阶上2级,或只能从第2级台阶上1级;f(n)=f(n-2)+f(n-1),n>3。又用递归逐个算Fibonacci就会超时,所...

2019-02-15 16:26:01 247

原创 HDU2013 蟠桃记[入门]

根据题意有f(n)/2-1 = f(n-1),整理后f(n) = 2 * ( f(n-1) + 1 ),另外f(1)=1。这就是递推关系。using namespace std;#include<iostream>int peach(int n) { if(n == 1) return 1; else { long res =...

2019-02-15 16:02:11 180

原创 HDU2004 成绩转换[入门]

查表法来实现,逻辑简单,程序运行速度快,语句简洁。0-9 ->0 E10-19->1 E|90-99->9 A100->10 Ausing namespace std;#include<iostream> int main(void){ int score; char convert[] = "EEEEEEDCBAA"; ...

2019-02-15 15:34:29 136

原创 HDU2010 水仙花数[入门]

using namespace std;#include <iostream> int main(void){ int m, n, count, i, t; while(cin>>m>>n) { // 水仙花数计数清零 count = 0; for(i=m; i<=n; ...

2019-02-15 13:04:44 189

原创 HDU2032 杨辉三角[入门]

using namespace std;#include <iostream>int pascal[30+1][30+1];void pascalgo(int n){ int i,j; for(i=0; i<n; i++) //注意,此处i<n,即为0到i有n个数字 for(j=0; j<=i; j++) //j

2019-02-15 12:40:23 167

原创 HDU1262 寻找素数对[入门]

问题分析:对于输入的偶数,先求得其一半的值,若不为奇数则减去1,然后从这个奇数开始从大到小用奇数试探。根据哥德巴赫猜想,一个偶数可以分解为两个素数之和,其中一个必然小于或等于这个偶数的一半。   有了上述的一个奇数p,对于输入的m来说,另外一个奇数就是m-p。  只要测试这两个奇数都是素数,就得到了差距最小的两个素数,输出即可。#include <stdio.h>#incl...

2019-02-15 12:40:15 285

原创 HDU2098 分拆素数和[入门]

一、我们首先来看如何求解质数定义:除了1和自身之外,无法被其它整数整除的数称之为质数,1不是质数。解法:使用回圈来求解,将一个指定的数除以所有小于它的数,若可以整除就不是质数://检验质数bool checkZS(int a){ for (int i = 2;i < a;i++) { if (0 == a%i) { ...

2019-02-15 12:39:26 129

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除