#include<stdio.h>
void get_N_generationArea(double n,double *start, double *end);
double Factorial(double n);
double getResult(double n, double *start, double *end);
double Array[100];
double n;
int main(void){
double start,end;
get_N_generationArea(2, &start, &end);
scanf("%lf", &n);
for(int i=0; i<n; i++)
scanf("%lf", &Array[i]);
for(int i=1; i<=n; i++){
printf("%d\n", (int)getResult(i, &start, &end)%1000000007);
}
return 0;
}
void get_N_generationArea(double n,double *start, double *end){
*start=0;
*end=0;
for(int i=1; i<=n; i++){
*end+=Factorial(i);
*start=*end-Factorial(i)+1;
}
}
double Factorial(double n){
double result=1;
for(int i=1; i<=n; i++){
result=(result*i);
}
return result;
}
double getResult(double generation, double *start, double *end){
double area;
get_N_generationArea(generation, start, end);
area=*end-*start+1;
for(int i=0; i<generation; i++){
area/=i+1;
*start+=area*(Array[i]-1);
*end=*start+area-1;
}
return *start;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1088 KB |
Output is correct |
2 |
Incorrect |
0 ms |
1088 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |