重新认识三观

0 0

Wow! Such String!   HDU 4850

西安邀请赛的D

从zzzz开始可以倒着卡值,顺着遍历能

弄出所有的符合要求的字符串

 1 #include <cstdio>
 2 #include <cstring>
 3 #include <queue>
 4 #include <map>
 5 #include <string>
 6 #include <cmath>
 7 #include <iostream>
 8 #include <time.h>
 9 #include <algorithm>
10 #include <map>    
11 using namespace std;
12 #define ll long long
13 #define maxn 200005
14 const ll mod = 1000000007;
15 int n, m, k, s, t;
16 int a[26][26][26][26];
17 int main(){
18     int x = 0;
19     while (scanf("%d", &n) != EOF){
20         if (n >= 456980){ printf("Impossible
"); continue; }
21         memset(a, 0, sizeof a);
22         a[25][25][25][25] = 1;
23         int z = 25, x = 25, c = 25, v = 25;
24         for (int i = 0; i < min(4,n); i++)printf("z");
25         for (int i = 4; i < n; i++)
26             for (int j = 0; j < 26; j++)
27                 if (!a[x][c][v][j]){
28                     a[x][c][v][j] = 1;
29                     printf("%c", 'a' + j);
30                     x = c; c = v; v = j;
31                     break;
32                 }
33         printf("
");
34     }
35 }
View Code

而,直接弄aaaa开始会因没zaaa然后aaa没有匹配的结束。。。

个数是26^4个4个重叠在一起就是26^4+3

aaaa  和aaab重叠就是aaaab就是2个4长度的重叠2+3

其实从什么开始是一样的。

因为总会有剩余的序列,只不过不好弄了就。。

所有又不是一样的。

可是人们会觉得从不同的开始能完全卡出所有的数么。。。

也刚好zzzz是最后一个。。。如果往这方面想,倒是会试出来。。。

原文地址:https://www.cnblogs.com/HaibaraAi/p/3832316.html