SP7586 NUMOFPAL - Number of Palindromes 题意翻译 求一个串中包含几个回文串 输入输出格式 输入格式: The string S. 输出格式: The value of function NumPal(s). 说明 $ 0 < |s| \le 1000$ 简单题,练个手. \(manacher\)求出每个位置回文串长度,把长度加在一起就可以了. Code: #include <cstdio> #include <cstring> cons…
题意翻译 求一个串中包含几个回文串 题目描述 Each palindrome can be always created from the other palindromes, if a single character is also a palindrome. For example, the string "malayalam" can be created by some ways: malayalam = m + ala + y + ala + m malayalam = m…
[SPOJ]NUMOFPAL - Number of Palindromes(Manacher,回文树) 题面 洛谷 求一个串中包含几个回文串 题解 Manacher傻逼题 只是用回文树写写而已.. #include<iostream> #include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<algorithm> #include<…
pprime解题报告 —— icedream61 博客园(转载请注明出处)------------------------------------------------------------------------------------------------------------------------------------------------[题目] 求a到b之间的所有回文素数(即又是素数又是回文数的数).[数据范围] 5<=a,b<=100,000,000[输入样例] 5…
dualpal解题报告 —— icedream61 博客园(转载请注明出处)------------------------------------------------------------------------------------------------------------------------------------------------[题目] 给出N和S,找出大于S的前N个双回文数. 双回文数定义:在二进制至十进制中的两种(或两种以上)进制下是回文数.[数据范围] 1…
Description 求一个串中包含几个回文串. Input 输入一个字符串\(S\) Output 包含的回文串的个数. 看到题解里面有人人写回文自动机. 有必要那么麻烦嘛 emmm 我们直接跑\(Manacher\)就好了啊. 答案就是以每一位为中心的回文串长度/2的和. (如果添加字符则为回文半径长度/2.) 这个就不多解释了.很明显的一个东西. 不能理解的话,可以看下这个 # a # a # b # a # a # 1 2 3 2 1 6 1 2 3 2 1 数字对应于每一个位置的回文…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 Java解法 Python解法 日期 题目地址:https://leetcode.com/problems/convert-a-number-to-hexadecimal/ 题目描述 Given an integer, write an algorithm to convert it to hexadecimal. For negative inte…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 日期 [LeetCode] 题目地址:https://leetcode.com/problems/number-of-boomerangs/ Difficulty: Easy 题目描述 Given n points in the plane that are all pairwise distinct, a "boomerang" is a…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 BFS解法 相似题目 参考资料 日期 题目地址:https://leetcode.com/problems/super-palindromes/description/ 题目描述 Let's say a positive integer is a superpalindrome if it is a palindrome, and it is als…
题目 题目描述 有一些数(如 21),在十进制时不是回文数,但在其它进制(如二进制时为 10101)时就是回文数. 编一个程序,从文件读入两个十进制数N.S.然后找出前 N 个满足大于 S 且在两种以上进制(二进制至十进制)上是回文数的十进制数. 数据范围 1 <= N <= 15 0 < S < 10000 样例输入 3 25 样例输出 26 27 28 解题思路 按照Palindromic Squares的解题思路,我们直接枚举所有的数字,然后判断是否满足条件,满足条件的输出即…
题目 题目描述 题目就是给定一个区间[a,b]((5 <= a < b <= 100,000,000)),我们需要找到这个区间内所有既是回文串又是素数的数字. 输入样例 5 500 输出样例 5 7 11 101 131 151 181 191 313 353 373 383 解题思路 因为数据范围特别大,如果我们直接枚举所有的素数然后再判断是不是回文串的话肯定会超时.在题目的下面有hints,其中就告诉我们要逆向思维,既然我们枚举素数太多了,那么我们就可以先枚举出所有可能的回文串(这个…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址: https://leetcode.com/problems/number-of-atoms/description/ 题目描述: Given a chemical formula (given as a string), return the count of each atom. An atomic element always starts with an upperc…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5062 题目意思:给出 N,找出 1 - 10^N 中满足 Beautiful Palindrome Numbers (BPN)的数量有多少. 满足 BPN 的条件有两个:(1)回文串   (2)对称的部分从左到右递增排放. (1)版本 1 (比较麻烦,建议看版本2)        46ms #include <iostream> #include <cstdio> #include &…
1.题目大意 输入字符串,判断其是否为回文串或镜像串.其中,输入的字符串中不含0,且全为合法字符.以下为所有的合法字符及其镜像: 2.思路 (1)考虑使用常量数组而不是if或switch来实现对镜像的判断,由此避免过于繁琐的过程. (2)" -- is not a palindrome."," -- is a mirrored string."," -- is a regular palindrome."," -- is a mirro…
题目链接:http://codeforces.com/problemset/problem/466/C 题目意思:给出一个 n 个数的序列你,问通过将序列分成三段,使得每段的和都相等的分法有多少种. 这个是详细的题解: http://codeforces.com/blog/entry/13758 代码也是按这个思路来做的,可怜我的做法改了 N 次总是得不到正确的结果--泪 #include <iostream> #include <cstdio> #include <cstd…
题目链接:http://codeforces.com/problemset/problem/464/A 题目意思:给出一个长度为 n 且是 tolerable 的字符串s,需要求出字典序最小的长度也为 n 额下一个tolerable 的 字符串,如果求不出则输出“NO”.字符串被认定为tolerable 需要满足:1.字符串的每一位都是取自字母表中前 p 个字母   2.不是回文串. 直接模拟就可以了.主要包括两个步骤: (1)从后往前遍历,找到目标位置,也就是需要改动的位置下标. 对于当前需要…
题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=342 题目意思:判断一行字符串为以下四种的哪一种:A regular palindrome,A mirrored string,A mirrored palindrome 和 is not a palindrome.A regular palindrome 就是我们见得最多的普通回文…
[九度OJ]题目1040:Prime Number 解题报告 标签(空格分隔): 九度OJ 原题地址:http://ac.jobdu.com/problem.php?pid=1040 题目描述: Output the k-th prime number. 输入: k≤10000 输出: The k-th prime number. 样例输入: 3 7 样例输出: 5 17 Ways 首先用C++做了一遍,刚开始没有AC的原因是判断素数的函数写的不对,没有处理2这个情况.后来发现每次停止循环的时候…
[LeetCode]Largest Number 解题报告 标签(空格分隔): LeetCode 题目地址:https://leetcode.com/problems/largest-number/#/description 题目描述: Given a list of non negative integers, arrange them such that they form the largest number. For example, given [3, 30, 34, 5, 9], t…
[LeetCode]375. Guess Number Higher or Lower II 解题报告(Python) 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址: https://leetcode.com/problems/guess-number-higher-or-lower-ii/description/ 题目描述: We are playing the Guess Game. The game is as f…
[LeetCode]792. Number of Matching Subsequences 解题报告(Python) 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址:https://leetcode.com/problems/number-of-matching-subsequences/description/ 题目描述: Given string S and a dictionary of words words,…
[LeetCode]137. Single Number II 解题报告(Python) 标签: LeetCode 题目地址:https://leetcode.com/problems/single-number-ii/description/ 题目描述: Given an array of integers, every element appears three times except for one, which appears exactly once. Find that singl…
[LeetCode]306. Additive Number 解题报告(Python) 标签(空格分隔): LeetCode 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.me/ 题目地址:https://leetcode.com/problems/additive-number/description/ 题目描述: Additive number is a string whose digits can form additive se…
[LeetCode]452. Minimum Number of Arrows to Burst Balloons 解题报告(Python) 标签(空格分隔): LeetCode 题目地址:https://leetcode.com/problems/minimum-number-of-arrows-to-burst-balloons/description/ 题目描述: There are a number of spherical balloons spread in two-dimensio…
[LeetCode]673. Number of Longest Increasing Subsequence 解题报告(Python) 标签(空格分隔): LeetCode 题目地址:https://leetcode.com/problems/number-of-longest-increasing-subsequence/description/ 题目描述: Given an unsorted array of integers, find the number of longest inc…
numtri解题报告 —— icedream61 博客园(转载请注明出处)------------------------------------------------------------------------------------------------------------------------------------------------[题目] 有一个数字的金字塔,形状如下    7   3 8  8 1 0 2 7 4 4 4 5 2 6 5 要从顶端开始走,每次只能向…
namenum解题报告 —— icedream61 博客园(转载请注明出处)------------------------------------------------------------------------------------------------------------------------------------------------[题目] 你有一个手机,键盘如下所示: 2: A,B,C 5: J,K,L 8: T,U,V 3: D,E,F 6: M,N,O 9:…
最近在准备找工作的算法题,刷刷LeetCode,以下是我的解题报告索引,每一题几乎都有详细的说明,供各位码农参考.根据我自己做的进度持续更新中......                              本文地址 LeetCode:Reverse Words in a String LeetCode:Evaluate Reverse Polish Notation LeetCode:Max Points on a Line LeetCode:Sort List LeetCode:Ins…
E - Just a Hook Time Limit:2000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u   Description In the game of DotA, Pudge’s meat hook is actually the most horrible thing for most of the heroes. The hook is made up of several consecutive m…
Unique Paths II Total Accepted: 31019 Total Submissions: 110866My Submissions Question Solution  Follow up for "Unique Paths": Now consider if some obstacles are added to the grids. How many unique paths would there be? An obstacle and empty spa…