标签:
1 #include "iostream" 2 #include "cstdio" 3 #include "cstring" 4 #include "algorithm" 5 using namespace std; 6 const __int64 mod = 1e9 + 7; 7 __int64 dp[1010]; 8 int pos[1010], n; 9 10 int main() 11 { 12 int i, j; 13 scanf("%d", &n); 14 for(i = 1; i <= n; ++i) 15 scanf("%d", &pos[i]); 16 for(i = 2; i <= n + 1; ++i) { 17 dp[i] = (dp[i - 1] + 1 + (dp[i - 1] - dp[pos[i - 1]] + mod) + 1) % mod; 18 } 19 printf("%I64d\n", dp[n + 1]); 20 }
标签:
原文地址:http://www.cnblogs.com/AC-Phoenix/p/4299064.html