2009 求数列的和
#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <math.h>
int main()
{
double n,m;
while(scanf("%lf%lf",&n,&m)!=EOF)
{
double sum = n;
int i = 0;
if(m<1000 && n<10000)
{
for(; i<m-1; i++)
{
n = sqrt(n);
sum += n;
}
printf("%.2f\n",sum);
}
}
return 0;
}
--------------------------------------------------
2010 水仙花数
#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
int main()
{
int m,n;
while(scanf("%d%d",&m,&n)!=EOF)
{
if(m>=100 && n<=999 &&m<=n)
{
int a,b,c,i,flag;
flag = 0;
for(i=m; i<=n; i++)
{
a = i/100;
b = i/10%10;
c = i%10;
if(i==(a*a*a + b*b*b + c*c*c))
{
if(flag==1)
printf(" ");//防止输出格式错误,最后的数后面没有空格
printf("%d",i);
flag = 1;
}
}
if(flag==0)
printf("no\n");
else
printf("\n");
}
}
return 0;
}
--------------------------------------------------
2011 多项式求和
#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
int main()
{
int m,n,j;
double tmp;
while(scanf("%d",&m)!=EOF)
{
if(m<100)
{
while(m--)
{
double ret = 0.0;
scanf("%d",&n);
if(n<1000)
{
for(j=1; j<=n; j++)
{
tmp = 1.0 / j;
if(j%2==0)
ret = ret - tmp;
else
ret = ret + tmp;
}
printf("%.2lf\n",ret);
}
}
}
}
return 0;
}