Back to the Training Home
Lesson: 24
Problem: 1549
Title: Least u Calculate e
Difficulty Level: 2.0
Date: FEB 27, 2009
Site: http://acm.tju.edu.cn/toj/
Another easy one. No need to take any input. Given a formula, you have to only print output.
Source code:
#include<stdio.h>
double F[10];
double Res[10];
void getFact() {
int i;
F[0] = 1;
for( i = 1; i<10; i++) {
F[i] = i*F[i-1];
}
}
void getRes() {
int i;
double sum = 1;
Res[0] = 1;
for(i = 1; i<10; i++) {
sum += F[i];
Res[i] = (1/F[i]) + Res[i-1];
if(i > 2) printf("%d %.9lf\n",i,Res[i]);
}
}
int main() {
getFact();
printf("n e\n");
printf("- -----------\n");
puts("0 1");
puts("1 2");
puts("2 2.5");
getRes();
return 0;
}
Back to the Training Home