Submission #9427

#TimeUsernameProblemLanguageResultExecution timeMemory
9427hodducUniting (kriii2_U)C++98
4 / 4
12 ms1868 KiB
#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 %= 1000000007; tmp *= i-1; tmp %= 1000000007; d[i] = tmp; } printf("%d\n", d[N]); }
#Verdict Execution timeMemoryGrader output
Fetching results...