#include <bits/stdc++.h>
#define N 10005
using namespace std;
typedef long long ll;
ll n, k, v[N], tot, used[N], mod = 1000007;
ll Pow(ll x, ll p)
{
if(!p) return 1LL;
ll ans = Pow(x, p/2);
ans = (ans*ans)%mod;
if(p & 1) return (ans*x)%mod;
return ans;
}
ll pos()
{
//for(ll i = 1; i <= k; i++) tot += solve(n, k);
set<ll> add;
ll q;
for(ll i = 1; i <= n; i++)
{
// tot += solve_suf(n - i, add.size()) * (v[i] - 1);
add.insert(v[i]);
tot = (tot + Pow(add.size(), n - i)*(v[i] - 1))%mod;
}
return (tot + 1)%mod;
}
int main()
{
ios::sync_with_stdio(false); cin.tie(0);
cin>>n;
for(ll i = 1; i <= n; i++)
{
cin>>v[i];
if(!used[v[i]]) k++;
used[v[i]] = 1;
}
cout<<pos()<<"\n";
}
Compilation message
teams.cpp: In function 'll pos()':
teams.cpp:27:5: warning: unused variable 'q' [-Wunused-variable]
ll q;
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
456 KB |
Output is correct |
3 |
Correct |
2 ms |
524 KB |
Output is correct |
4 |
Correct |
2 ms |
524 KB |
Output is correct |
5 |
Correct |
3 ms |
528 KB |
Output is correct |
6 |
Correct |
3 ms |
528 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
528 KB |
Output is correct |
2 |
Incorrect |
3 ms |
528 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
688 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
688 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
688 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
688 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
688 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
9 ms |
1244 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
1244 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
1244 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |