hdu 3374 String Problem 最小表示法 view code#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <map> #include <string> using namespace std; const int N = 10010; int n; char s[105]; map<…
Give you a string with length N, you can generate N strings by left shifts. For example let consider the string “SKYLONG”, we can generate seven strings: String Rank SKYLONG 1 KYLONGS 2 YLONGSK 3 LONGSKY 4 ONGSKYL 5 NGSKYLO 6 GSKYLON 7 and lexicograp…
HDU 1248 寒冰王座(全然背包:入门题) http://acm.hdu.edu.cn/showproblem.php?pid=1248 题意: 不死族的巫妖王发工资拉,死亡骑士拿到一张N元的钞票(记住,仅仅有一张钞票),为了防止自己在战斗中频繁的死掉,他决定给自己买一些道具,于是他来到了地精商店前. 死亡骑士:"我要买道具!" 地精商人:"我们这里有三种道具,血瓶150块一个,魔法药200块一个,无敌药水350块一个." 死亡骑士:"好的,给我一个血…
题目链接:https://vjudge.net/problem/HDU-3374 String Problem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3646    Accepted Submission(s): 1507 Problem Description Give you a string with length N,…
链接: https://vjudge.net/problem/HDU-3374 题意: Give you a string with length N, you can generate N strings by left shifts. For example let consider the string "SKYLONG", we can generate seven strings: String Rank SKYLONG 1 KYLONGS 2 YLONGSK 3 LONGS…
题目给出一个字符串,由a~z表示甜度,随字典序增大,字符串首尾相连形成一个圈,要求从一个位置开始字典序最大的字符串,输出位置以及是顺时针还是逆时针表示.顺时针用0表示,逆时针用1表示. 此题只需要查找字符串的最大字典序排列即可,模拟对字符串的翻转以及排列操作,可以用二分来查找位置来节省时间. 最小表示法模板: int getmin(char *s){ int n=strlen(s); ,j=,k=,t; while(i<n && j<n && k<n){…
传送门:https://ac.nowcoder.com/acm/contest/887/A 题意:大意就是给你一个只含有0和1的字符串,找出一种分割方法,使得每个分割出的字符串都是在该字符串自循环节中最小 思路: 一: 最小表示法的模板题了,数据范围比较小.每次枚举字符串的最长长度,用最小表示法进行判断即可. 最小表示法的介绍:https://oi-wiki.org/string/minimal-string/ 代码: #include<bits/stdc++.h> using namespa…
题目大意: 与别的裸题的唯一不同点是其符号的ASCII码值在3 ~ 254 之间. 算法讨论: 最小表示法直接上.但是唯一不同的就是注意这里的字符范围,用char是会get wa的,所以要用unsigned char.这两者的区别就是可以表示的ASCII范围不同. char是有符号位的,其可以表示的范围是-128~127, 而unsigned char 可以表示的范围是 0~ 255. 至于输入输出,和原来是一样的.只改一个关键字即可. 不贴代码了.…
题目大意: 就是求一个串的最大最小表示法的开始下标,然后求有多少个做大最小表示,输出格式为 最小表示下标 它的个数 最大表示下标 它的个数 基本思路: 最小最大表示法模板题,然后求一下循环节,很容易知道,循环节和最大最小表示数量上相等,然后问题就解决啦: 代码如下: #include<cstdio> #include<cstdlib> #include<cstring> #include<algorithm> using namespace std; con…
Give you a string with length N, you can generate N strings by left shifts. For example let consider the string “SKYLONG”, we can generate seven strings: String Rank SKYLONG 1 KYLONGS 2 YLONGSK 3 LONGSKY 4 ONGSKYL 5 NGSKYLO 6 GSKYLON 7 and lexicograp…