hdu 2609 字符串最小表示法 虽然不是很懂 还是先贴上来吧。/,。/
2024-09-05 04:00:19
还需要再消化一下这个算法。。 今天没有时间了,, 六级过了 就有大把时间 快活啊!
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<set>
using namespace std;
int getmin(string s)
{
int n=s.size();
int i=,j=,k=,t;
while(i<n && j<n && k<n)
{
t=s[(i+k)%n]-s[(j+k)%n];
if (!t) k++;
else
{
if (t>) i+=k+;
else j+=k+;
if (i==j) j++;
k=;
}
}
return i<j?i:j;
}
int main()
{
cin.sync_with_stdio(false);
int t;
while(cin>>t)
{
set<string> fuck;
for(int i=;i<=t;i++)
{
string ss;
cin>>ss;
int temp=getmin(ss);
int len=ss.size();
string zz;
int z=temp,ret;
for(ret=;ret<ss.size();ret++)
{
zz+=ss[z%len];
z++;
}
fuck.insert(zz);
}
cout<<fuck.size()<<endl;
}
return;
}
最新文章
- 遍历 Input检测是否有重复的值
- 自绘制HT For Web ComboBox下拉框组件
- CI框架源码阅读笔记6 扩展钩子 Hook.php
- Appium 解决不能输入中文字符问题
- oracle空表导出的问题
- js 动态 activex 组件
- Python中的SET集合操作
- Chapter3:字符串、向量和数组
- 稀疏表示(sparse representation)和字典学习
- yii 获取系统级请求参数的常用方法
- Android 使用LinearLayout.getChildAt(i)获取一个线性布局的view,并实现content中实现方法
- Windows Azure 数据安全(清理和泄漏)
- [PHP] assert()断言检测函数
- 【Java】利用注解和反射实现一个";低配版";的依赖注入
- Ex 6_5棋子放置问题_第八次作业
- Java反射《一》获取类
- pom格式
- windows 搭建 angular2 开发环境--白纸新手可以参考一下
- css 计算属性 calc的使用
- Note: further occurrences of HTTP header parsing errors will be logged at DEBUG level
热门文章
- 黑马vue---59-60、组件中的data和methods
- Python3 编程之字符串处理
- Linux命令:hexdump
- Job for keepalived.service failed because the control process exited with error code. See ";systemctl status keepalived.service"; and ";journalctl -xe"; for details.
- 记录学习Linux遇到的问题
- Eclipse添加Android library 错误的原因
- mac配置maven项目的方法(含导入selenium包)
- uWSGI 漏洞复现(CVE-2018-7490)
- Vue父子组件传值$parent , ref,$refs,props大总结
- 洛谷 题解 CF711A 【Bus to Udayland】