Submission #3686

# Submission time Handle Problem Language Result Execution time Memory
3686 2013-08-31T07:41:29 Z pmpmp Inherited disease (kriii1_I) C++
1 / 1
0 ms 1676 KB





#include <iostream>
#include <algorithm>
#include <stdio.h>
long long dd, h[200], hh[200];
int main ()
{
   // freopen("input.txt", "r", stdin);
   // freopen("output.txt", "w", stdout);
    
    int a, b, c, d;
    int i, j, k;
    
    hh[0]=1; h[0]=0;
    for(i=1;i<=100;i++){hh[i]=hh[i-1]*i; hh[i]=hh[i]%1000000007; }//printf("(%lld\n", hh[i]);}
    for(i=1;i<=100;i++){h[i]=h[i-1]+hh[i-1]; h[i]=h[i]%1000000007; }//printf("%lld\n", h[i]);}
    //printf("//%lld\n", 1000000006*1000000006);
    scanf("%d", &a);
    for(i=1;i<=a;i++)
    {
         scanf("%d", &d);
         //dd=( ( (h[i]-1)%1000000007 ) + d%1000000007 + ( ( (dd*1000000007-h[i-1]) % 1000000007 ) * i ) % 1000000007 ) % 1000000007;
         dd=( ( (h[i]-1)%1000000007 ) + d%1000000007 + ( ( (dd%1000000007-h[i-1]%1000000007+1000000007) % 1000000007 ) * i ) % 1000000007 ) % 1000000007;
         printf("%lld\n", dd);
    }
}

# Verdict Execution time Memory Grader output
1 Correct 0 ms 1676 KB Output is correct
2 Correct 0 ms 1676 KB Output is correct
3 Correct 0 ms 1676 KB Output is correct
4 Correct 0 ms 1676 KB Output is correct
5 Correct 0 ms 1676 KB Output is correct
6 Correct 0 ms 1676 KB Output is correct
7 Correct 0 ms 1676 KB Output is correct
8 Correct 0 ms 1676 KB Output is correct
9 Correct 0 ms 1676 KB Output is correct
10 Correct 0 ms 1676 KB Output is correct
11 Correct 0 ms 1676 KB Output is correct
12 Correct 0 ms 1676 KB Output is correct
13 Correct 0 ms 1676 KB Output is correct
14 Correct 0 ms 1676 KB Output is correct
15 Correct 0 ms 1676 KB Output is correct
16 Correct 0 ms 1676 KB Output is correct
17 Correct 0 ms 1676 KB Output is correct
18 Correct 0 ms 1676 KB Output is correct
19 Correct 0 ms 1676 KB Output is correct
20 Correct 0 ms 1676 KB Output is correct