#include <iostream>
#include <algorithm>
#include <string.h>
#include <cstdio>
#include <vector>
using namespace std;
const int maxn=;
struct elem
{
char str[];
int len;
bool operator <(const elem &rhs)const{
return len<rhs.len||(len==rhs.len&&strcmp(str,rhs.str)<=);
}
bool operator == (const elem &rhs)const{
return len==rhs.len&&strcmp(str,rhs.str)==;
}
}P[maxn];
char s[];
int MinRepresstation(char * S, int len ) {
int i = , j = , k = ;
while(i < len && j < len)
{
k = ;
while(k < len && S[(i + k)%len] == S[(j + k)%len])
k++;
if(k >= len)
break;
if(S[(i + k)%len] > S[(j + k)%len])
i = max(i + k + , j + );
else
j = max(i + , j + k + );
}
return min(i ,j);
}
int main()
{
int n;
while(scanf("%d",&n)==)
{
for(int i=; i<n; i++)
{
scanf("%s",s);
P[i].len=strlen(s);
int d=MinRepresstation(s,P[i].len);
for(int j=;j<P[i].len; j++)
P[i].str[j]=s[ (d+j)%P[i].len ];
P[i].str[P[i].len]=;
}
sort(P,P+n);
int num=unique(P,P+n)-P;
printf("%d\n",num); } return ;
}

最新文章

  1. Eclipse 开发 jsp
  2. js获取对象、数组的实际长度,元素实际个数
  3. Lambda表达式实现有限状态机
  4. JS判断字符串是否包含某字符串 indexOf()方法使用
  5. .net之简单工厂模式
  6. Python打印乘法口诀表
  7. 《Linux命令行与shell脚本编程大全》 第四章
  8. maven入门(1-1)maven是什么?
  9. 见过的最全的iOS面试题
  10. 教程:使用cPanel管理域名和数据库
  11. Java-redis-雪崩优化
  12. Java多线程之sleep方法阻塞线程-模拟时钟
  13. iOS之iOS11、iPhone X、Xcode9 适配指南
  14. 2.Yum仓库优化
  15. 2018-2019-2 网络对抗技术 20165318 Exp1 PC平台逆向破解
  16. C++ 四种新式类型转换
  17. java学习第四周
  18. Oracle EBS AP 应付核销到确定一行预付款
  19. C和C++的内存操作小贴士(一):const char*的内存释放问题
  20. js函数柯里化

热门文章

  1. 抽屉之Tornado实战(2)--数据库表设计
  2. rman checksyntax和解决RMAN-01009: syntax error: found &quot;dot&quot;
  3. rem设置
  4. es内部的多线程异步并发控制
  5. AsyncStorage和Promise配合使用
  6. 前端框架之Vue(5)-条件渲染
  7. HBuilder 自动整理代码格式快捷键设置
  8. swiper默认第二个且居中
  9. 利用Python实现简单的相似图片搜索的教程
  10. xcodebuild 打包