标签:
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 830 Accepted Submission(s): 232

#include<stdio.h>
#include<string.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<string>
#include<stdlib.h>
#include<algorithm>
using namespace std;
typedef long long LL;
const int maxn = 1e6;
const LL mod = 1000000007;
int a[maxn];
int main(){
int cas ;
scanf("%d",&cas);
while(cas--){
int n, flag = 0, c = 0;
scanf("%d",&n);
for(int i = 1; i < n; i++){
scanf("%d",&a[i]);
if(!a[i]) c++;
if(a[i] > n-i){ //限制条件
flag = 1;
}
if(a[i-1] != 0 && a[i-1] - a[i] != 1){ //减1递减
flag = 1;
}
}
if(flag){
puts("0"); continue;
}
LL ans = 26;
for(int i = 1; i <= c; i++){
ans = (ans * 25) % mod;
}
printf("%lld\n",ans);
}
return 0;
}
/*
55
5
0 1 0 4
5
0 1 0 2
4
3 2 1
5
0 1 2 0
7
0 0 3 2 1 0
*/
HDU 5635 ——LCP Array ——————【想法题】
标签:
原文地址:http://www.cnblogs.com/chengsheng/p/5248081.html