# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
9419 | hodduc | Uniting (kriii2_U) | C++98 | 12 ms | 1868 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<stdio.h>
long long a, b;
int num[100001];
int d[100001];
int N;
int main()
{
scanf("%d", &N);
for(int i = 0; i < N; i++) scanf("%d", &num[i]);
// sum
long long sum = num[0];
for(int i = 1; i < N; i++)
{
a += sum * num[i];
sum += num[i];
}
printf("%lld\n", a);
d[1] = 1;
long long tmp = 0;
for(int i = 2; i <= N; i++){
tmp = d[i-1];
tmp *= i;
tmp *= i-1;
tmp %= 1000000007;
d[i] = tmp;
}
printf("%d\n", d[N]);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |