# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
19048 |
2016-02-17T09:49:36 Z |
kriii |
목공 (kriii4_A) |
C++14 |
|
7000 ms |
1184 KB |
#include <stdio.h>
const long long mod = 1092616193;
long long fpow(long long a, long long p)
{
a %= mod;
p = (p % (mod - 1) + mod - 1) % (mod - 1);
long long r = 1;
while (p){
if (p & 1) r = r * a % mod;
a = a * a % mod;
p >>= 1;
}
return r;
}
int main()
{
int N,Q[16006];
long long M,S=0; scanf ("%d %lld",&N,&M);
for (int i=0;i<N;i++){
scanf ("%d",&Q[i]);
S += Q[i];
}
long long v = fpow(S,-1);
const int sz = 20000;
long long A[sz] = {0,};
for (int i=N;i<=M;i++){
long long &a = A[i%sz];
a = 0;
for (int j=0;j<N;j++) a = (a + A[(i-N+j)%sz] * Q[j]) % mod;
a = a * v % mod;
a++;
if (a >= mod) a = 0;
}
printf ("%lld\n",A[M%sz]);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
1180 KB |
Output is correct |
2 |
Correct |
23 ms |
1184 KB |
Output is correct |
3 |
Correct |
25 ms |
1176 KB |
Output is correct |
4 |
Correct |
24 ms |
1180 KB |
Output is correct |
5 |
Correct |
26 ms |
1176 KB |
Output is correct |
6 |
Correct |
24 ms |
1176 KB |
Output is correct |
7 |
Correct |
23 ms |
1180 KB |
Output is correct |
8 |
Correct |
27 ms |
1180 KB |
Output is correct |
9 |
Correct |
21 ms |
1180 KB |
Output is correct |
10 |
Correct |
25 ms |
1180 KB |
Output is correct |
11 |
Correct |
24 ms |
1180 KB |
Output is correct |
12 |
Correct |
24 ms |
1180 KB |
Output is correct |
13 |
Correct |
24 ms |
1184 KB |
Output is correct |
14 |
Correct |
27 ms |
1180 KB |
Output is correct |
15 |
Correct |
25 ms |
1184 KB |
Output is correct |
16 |
Correct |
23 ms |
1180 KB |
Output is correct |
17 |
Correct |
23 ms |
1176 KB |
Output is correct |
18 |
Correct |
24 ms |
1176 KB |
Output is correct |
19 |
Correct |
0 ms |
1180 KB |
Output is correct |
20 |
Correct |
0 ms |
1176 KB |
Output is correct |
21 |
Correct |
15 ms |
1184 KB |
Output is correct |
22 |
Correct |
16 ms |
1176 KB |
Output is correct |
23 |
Correct |
12 ms |
1180 KB |
Output is correct |
24 |
Correct |
16 ms |
1176 KB |
Output is correct |
25 |
Correct |
16 ms |
1180 KB |
Output is correct |
26 |
Correct |
12 ms |
1180 KB |
Output is correct |
27 |
Correct |
16 ms |
1180 KB |
Output is correct |
28 |
Correct |
16 ms |
1180 KB |
Output is correct |
29 |
Correct |
16 ms |
1176 KB |
Output is correct |
30 |
Correct |
16 ms |
1176 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
7000 ms |
1176 KB |
Program timed out |
2 |
Halted |
0 ms |
0 KB |
- |