【HDOJ】4162 Shape Number
循环串的最小表示法。
/* */
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <deque>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <climits>
#include <cctype>
#include <cassert>
#include <functional>
#include <iterator>
#include <iomanip>
using namespace std;
//#pragma comment(linker,"/STACK:102400000,1024000") #define sti set<int>
#define stpii set<pair<int, int> >
#define mpii map<int,int>
#define vi vector<int>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define rep(i, a, n) for (int i=a;i<n;++i)
#define per(i, a, n) for (int i=n-1;i>=a;--i)
#define clr clear
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define lson l, mid, rt<<1
#define rson mid+1, r, rt<<1|1 const int maxl = 3e5+;
char M[][];
char s[maxl];
char d[maxl];
int len; void init() {
rep(i, , ) {
rep(j, , ) {
M[i][j] = (j-i+)% + '';
}
}
} int minStr() {
int i, j, k;
int tmp; i = ;
j = ;
k = ;
while (i<len && j<len && k<len) {
tmp = d[(i+k)%len] - d[(j+k)%len];
if (tmp == ) {
++k;
} else {
if (tmp < )
j += k+;
else
i += k+;
if (i == j)
++j;
k = ;
}
} return i<j ? i:j;
} int main() {
ios::sync_with_stdio(false);
#ifndef ONLINE_JUDGE
freopen("data.in", "r", stdin);
freopen("data.out", "w", stdout);
#endif int k; init();
while (scanf("%s", s) != EOF) {
len = strlen(s);
s[len] = s[];
rep(i, , len) {
d[i] = M[s[i]-''][s[i+]-''];
}
#ifndef ONLINE_JUDGE
d[len] = '\0';
puts(d);
#endif
k = minStr();
rep(i, , len) {
putchar(d[(k+i)%len]);
}
putchar('\n');
} #ifndef ONLINE_JUDGE
printf("time = %d.\n", (int)clock());
#endif return ;
}
【HDOJ】4162 Shape Number的更多相关文章
- 【HDOJ】3948 The Number of Palindromes
后缀数组求不重复回文子串数目.注意dp数组. /* 3948 */ #include <iostream> #include <sstream> #include <st ...
- 【HDOJ】1018 Big Number
数学题,还是使用log避免大数,但是不要忘记需要+1,因为0也是1位,log(100)= 2,但却是3位. #include <stdio.h> #include <math.h&g ...
- 【HDOJ】3006 The Number of set
数据量这么小,果断状态压缩+dp. /* 3006 */ #include <iostream> #include <string> #include <map> ...
- 【HDOJ】5179 beautiful number
DFS. /* 5179 */ #include <iostream> #include <algorithm> #include <map> #include & ...
- 【转】oracle数据库NUMBER数据类型
原文:http://www.jb51.net/article/37633.htm NUMBER ( precision, scale)a) precision表示数字中的有效位;如果没有指定prec ...
- 【CF245H】Queries for Number of Palindromes(回文树)
[CF245H]Queries for Number of Palindromes(回文树) 题面 洛谷 题解 回文树,很类似原来一道后缀自动机的题目 后缀自动机那道题 看到\(n\)的范围很小,但是 ...
- 论文速读(Chuhui Xue——【arxiv2019】MSR_Multi-Scale Shape Regression for Scene Text Detection)
Chuhui Xue--[arxiv2019]MSR_Multi-Scale Shape Regression for Scene Text Detection 论文 Chuhui Xue--[arx ...
- 【BZOJ4026】dC Loves Number Theory 分解质因数+主席树
[BZOJ4026]dC Loves Number Theory Description dC 在秒了BZOJ 上所有的数论题后,感觉萌萌哒,想出了这么一道水题,来拯救日益枯竭的水题资源. 给 ...
- 【LeetCode】375. Guess Number Higher or Lower II 解题报告(Python)
[LeetCode]375. Guess Number Higher or Lower II 解题报告(Python) 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://f ...
随机推荐
- Mysql 冷备份批处理
@Rem Generate today date @echo wscript.echo dateadd("d",0,date)>GetOldDate.vbs @for /f ...
- Hudson的安装配置
Hudson的安装配置 目录 一.正文... 2 1.安装配置jdk. 2 2.安装配置tomcat7. 2 3.安装Hudson. 2 4.启动tomcat. 2 5.初识Hudson. 3 6 ...
- iOS夯实:ARC时代的内存管理
iOS夯实:ARC时代的内存管理 文章转自 ARC时代的内存管理 什么是ARC Automatic Reference Counting (ARC) is a compiler feature tha ...
- [.Net MVC] 使用 log4net 日志框架
项目:后台管理平台 意义:项目开发中提出增加日志功能,对关键的操作.程序运行中的错误信息进行记录,这对程序部署后的调试有很大意义. 注:本文只是对网上搜集的信息进行了整合,以备今后查询. 关键字:.N ...
- Java线程练习
/*线程练习创建两个线程,与主线程交替运行 */ class Text extends Thread{ private String name; Text(String name) ...
- 09_httpclient测试SOAP协议
[工程截图]注意:无需使用Wsimport生成客户端代码 [HttpClient.java] import java.io.ByteArrayOutputStream; import java.io. ...
- Android SDK下载技巧
转载说明 本篇文章可能已经更新,最新文章请转:http://www.sollyu.com/android-sdk-download-tips/ 说明 想必在国内的你,是不是经常在下载Android S ...
- 蝇量模式(Flyweight Pattern)
蝇量模式:让某个类的一个实例能用来提供许多“虚拟实例”. 在有大量对象时,有可能造成内存溢出,把其中共同的部分抽象出来,如果有相同的业务请求,直接返回在内存中已有的对象,避免重复创建.(JAVA中的S ...
- postal.js使用
requirejs.config({ //默认情况下模块所在目录为js/lib baseUrl: './', //当模块id前缀为app时,他便由js/app加载模块文件 //这里设置的路径是相对与b ...
- 换行符‘\n’和回车符‘\r’
顾名思义,换行符就是另起一行,回车符就是回到一行的开头,所以我们平时编写文件的回车符应该确切来说叫做回车换行符 '\n' 10 换行(newline)'\r' 13 回车(return) 也可以表示为 ...