# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
9840 | effserv | Uniting (kriii2_U) | C++98 | 16 ms | 1360 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 <cstdio>
#include <algorithm>
using namespace std;
typedef long long ll;
int main()
{
int N;
scanf("%d", &N);
ll a;
scanf("%lld", &a);
ll A = (ll)a;
ll C = 0;
int arr[100001] = { (int)a };
for (int i = 0; i < N - 1; i++)
{
scanf("%lld", &a);
arr[i + 1] = (int)a;
C += A*a;
A += a;
}
sort(arr, arr + N);
printf("%lld\n", C);
ll mod = 1000000007;
ll bigmod = 10000000000000;
ll S = 1;
int cnt = 1;
for (int i = 0; i < N - 1; i++)
{
if (arr[i] != arr[i + 1])
cnt++;
}
for (int i = cnt; i >= 1; i--)
{
S*= (ll)i;
S %= bigmod;
}
printf("%lld\n", S%mod);
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |