hdu 2010~2014

hdu 2010

求一个区间内的水仙花数。

水,但是要注意给的区间的两边大小要先排序

 1 #include<stdio.h>
 2 int main()
 3 {
 4     int n,m,i,count=0,x1,x2,x3;
 5     while (scanf("%d%d",&m,&n)!=EOF)
 6     {
 7         if (m>n)
 8         {
 9             i=m;
10             m=n;
11             n=i;
12         }
13         for (i=m;i<=n;i++)
14         {
15             x1=i/100;
16             x2=i/10-10*x1;
17             x3=i-100*x1-10*x2;
18             if (x1*x1*x1+x2*x2*x2+x3*x3*x3==i)
19             {
20                 if (count!=0) printf(" ");
21                 count++;
22                 printf("%d",i);
23             }
24         }
25         if (count==0) printf("no");
26         printf("\n");
27         count=0;
28     }
29     return 0;
30 }

hdu 2011

多项式求和,水

 1 #include<stdio.h>
 2 int main()
 3 {
 4     int m,n,i,j;
 5     double sum=0,a=-1;
 6     while (scanf("%d",&m)!=EOF)
 7     {
 8         for (i=1;i<=m;i++)
 9         {
10             scanf("%d",&n);
11             for (j=1;j<=n;j++)
12             {
13                 a*=-1;
14                 sum+=a*1/(double)j;
15             }
16             printf ("%.2f\n",sum);
17             sum=0;
18             a=-1;
19         }
20     }
21     return 0;
22 }

hdu 2012

素数判定

水,筛法或者直接循环判

 1 #include<stdio.h>
 2 #include<math.h>
 3 int prim(int);
 4 int main()
 5 {
 6     int x,y,n,i,m,t=1;
 7     while (scanf("%d%d",&x,&y)!=EOF)
 8     {
 9         if (x!=0||y!=0){
10         if (x>y)
11         {
12             n=x;
13             x=y;
14             y=n;
15         }
16         for (n=x;n<=y;n++)
17         {
18             m=n*n+n+41;
19             for (i=m/2;i>=1;i--)
20             {
21                 if (m%i==0) break;
22             }
23             if (i!=1) break;
24         }
25         if (n==y+1) printf("OK\n");
26         else printf("Sorry\n");
27         }
28     }
29     return 0;
30 }
31
32 int prim(int a)
33 {
34     int i;
35     for (i=(int)sqrt((double)a);i>=1;i--)
36     {
37         if (a/i==0) break;
38     }
39     if (i==1) return 1;
40     return 0;
41 }

hdu 2013

 1 #include<stdio.h>
 2 int main()
 3 {
 4     int day,sum,i;
 5     while (scanf("%d",&day)!=EOF)
 6     {
 7         sum=1;
 8         for (i=1;i<day;i++) sum=2*(sum+1);
 9         printf("%d\n",sum);
10     }
11     return 0;
12 }

hdu 2014

去最高最低分求平均数

 1 #include<stdio.h>
 2 int main()
 3 {
 4     int n,sum,max,min,i,a;
 5     double ave;
 6     while (scanf("%d",&n)!=EOF)
 7     {
 8         sum=0;
 9         max=0;
10         min=32767;
11         for (i=1;i<=n;i++)
12         {
13             scanf("%d",&a);
14             sum+=a;
15             if (a>max) max=a;
16             if (a<min) min=a;
17         }
18         ave=double(sum-max-min)/(n-2);
19         printf("%.2f\n",ave);
20     }
21     return 0;
22 }

时间: 2024-11-13 06:35:08

hdu 2010~2014的相关文章

hdu 5008(2014 ACM/ICPC Asia Regional Xi&#39;an Online ) Boring String Problem(后缀数组&amp;二分)

Boring String Problem Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 219    Accepted Submission(s): 45 Problem Description In this problem, you are given a string s and q queries. For each que

【HDU 2010】水仙花数

http://acm.hdu.edu.cn/showproblem.php?pid=2010 春天是鲜花的季节,水仙花就是其中最迷人的代表,数学上有个水仙花数,他是这样定义的:“水仙花数”是指一个三位数,它的各位数字的立方和等于其本身,比如:153=1^3+5^3+3^3.现在要求输出所有在m和n范围内的水仙花数. Solution:水仙花数又称阿姆斯特朗数,没有直接规律,只能暴力求解. 有限数列,打表算了(懒写暴力) 使用在线算法打大表: 1:  1, 2, 3, 4, 5, 6, 7, 8,

hdu 2010 水仙花数

水仙花数 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 124377    Accepted Submission(s): 36790 Problem Description 春天是鲜花的季节,水仙花就是其中最迷人的代表,数学上有个水仙花数,他是这样定义的: "水仙花数"是指一个三位数,它的各位数字的立方和等于其本身,比如:

HDU 5000 2014 ACM/ICPC Asia Regional Anshan Online DP

Clone Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/65536K (Java/Other) Total Submission(s) : 8   Accepted Submission(s) : 5 Font: Times New Roman | Verdana | Georgia Font Size: ← → Problem Description After eating food from Chernobyl,

hdu 5078 2014鞍山现场赛 水题

http://acm.hdu.edu.cn/showproblem.php?pid=5078 现场最水的一道题 连排序都不用,因为说了ti<ti+1 //#pragma comment(linker, "/STACK:102400000,102400000") #include <cstdio> #include <cstring> #include <algorithm> #include <string> #include &l

[hdu 5032]2014北京网络赛Always Cook Mushroom 离散化+离线线段树/树状数组

Always Cook Mushroom Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 196    Accepted Submission(s): 54 Problem Description Matt has a company, Always Cook Mushroom (ACM), which produces high-q

hdu 5073 2014鞍山现场赛题 物理题

http://acm.hdu.edu.cn/showproblem.php?pid=5073 推公式即可,质心公式segma(xi*wi)/segma(wi) 最终剩下的一定是连续n-k个星 然后枚举左边需要移除几个星即可 计算I的时候展开来算 比较坑的地方在于,星星的位置如果是int型,一定记得Double计算的时候 *1.0或者直接将位置数组声明为double  否则WA到死... //#pragma comment(linker, "/STACK:102400000,102400000&q

hdu 5078(2014鞍山现场赛 I题)

数据 表示每次到达某个位置的坐标和时间 计算出每对相邻点之间转移的速度(两点间距离距离/相隔时间) 输出最大值 Sample Input252 1 9//t x y3 7 25 9 06 6 37 6 01011 35 6723 2 2929 58 2230 67 6936 56 9362 42 1167 73 2968 19 2172 37 8482 24 98 Sample Output9.219544457354.5893762558 1 # include <iostream> 2 #

HDU 2010

#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> int Is_SXH(int num); int main() { int in1, in2; int temp = 0; int flag = 0; while (scanf("%d %d", &in1, &in2) != EOF){ flag = 0; temp = in1; for (; temp <= in2; temp++){ if (Is_