-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1202.cpp
More file actions
45 lines (38 loc) · 926 Bytes
/
Copy path1202.cpp
File metadata and controls
45 lines (38 loc) · 926 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*************************************************************************
> File Name: 1202.cpp
> Author: dulun
> Mail: dulun@xiyoulinux.org
> Created Time: 2016年03月03日 星期四 21时22分07秒
************************************************************************/
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#define LL long long
using namespace std;
const int N = 100086;
const int maxv = 1000000000+7;
LL dp[N];
int f[N];
int a[N];
int main()
{
int n;
scanf("%d", &n);
memset(f, 0, sizeof(f));
for(int i = 1; i <= n; i++ ) scanf("%d", &a[i]);
dp[0] = 1;
for(int i = 1; i <= n; i++)
{
dp[i] = (dp[i-1] * 2);// % maxv;
if(f[a[i]] > 0)
{
dp[i] = (dp[i] + maxv - dp[f[a[i]] - 1]) % maxv;
}
f[a[i]] = i;
}
cout<< (dp[n]+maxv-1) % maxv;
return 0;
}