# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
19047 |
2016-02-17T09:48:51 Z |
kriii |
목공 (kriii4_A) |
C++14 |
|
475 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] * 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 |
19 ms |
1180 KB |
Output is correct |
2 |
Correct |
21 ms |
1184 KB |
Output is correct |
3 |
Correct |
23 ms |
1176 KB |
Output is correct |
4 |
Correct |
22 ms |
1180 KB |
Output is correct |
5 |
Correct |
24 ms |
1180 KB |
Output is correct |
6 |
Correct |
22 ms |
1176 KB |
Output is correct |
7 |
Correct |
21 ms |
1180 KB |
Output is correct |
8 |
Correct |
24 ms |
1180 KB |
Output is correct |
9 |
Correct |
22 ms |
1176 KB |
Output is correct |
10 |
Correct |
23 ms |
1176 KB |
Output is correct |
11 |
Correct |
22 ms |
1176 KB |
Output is correct |
12 |
Correct |
22 ms |
1184 KB |
Output is correct |
13 |
Correct |
22 ms |
1176 KB |
Output is correct |
14 |
Correct |
24 ms |
1184 KB |
Output is correct |
15 |
Correct |
22 ms |
1176 KB |
Output is correct |
16 |
Correct |
21 ms |
1184 KB |
Output is correct |
17 |
Correct |
21 ms |
1180 KB |
Output is correct |
18 |
Correct |
21 ms |
1176 KB |
Output is correct |
19 |
Correct |
0 ms |
1180 KB |
Output is correct |
20 |
Correct |
0 ms |
1180 KB |
Output is correct |
21 |
Correct |
14 ms |
1176 KB |
Output is correct |
22 |
Correct |
10 ms |
1176 KB |
Output is correct |
23 |
Correct |
14 ms |
1180 KB |
Output is correct |
24 |
Correct |
14 ms |
1180 KB |
Output is correct |
25 |
Correct |
10 ms |
1176 KB |
Output is correct |
26 |
Correct |
14 ms |
1180 KB |
Output is correct |
27 |
Correct |
14 ms |
1180 KB |
Output is correct |
28 |
Correct |
14 ms |
1176 KB |
Output is correct |
29 |
Correct |
14 ms |
1176 KB |
Output is correct |
30 |
Correct |
10 ms |
1176 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
475 ms |
1176 KB |
SIGSEGV Segmentation fault |
2 |
Halted |
0 ms |
0 KB |
- |