LA 2889 (找规律) Palindrome Numbers】的更多相关文章

输出第n个回文数. 规律就是一位和两位的回文数各有9个,三位四位的回文数各有90个,以此类推. 给出n,可以先判定一下第n个回文数的位数,然后后面也不难推,但是有很多细节需要注意. #include <cstdio> #include <algorithm> #include <cassert> using namespace std; typedef long long LL; ; LL a[maxl + ], sum[maxl + ], pow10[maxl]; i…
题意: 有n堆石子,两个人轮流取,每次只能取一堆的至少一个至多一半石子,直到不能取为止. 判断先手是否必胜. 分析: 本题的关键就是求SG函数,可是直接分析又不太好分析,于是乎找规律. 经过一番“巧妙”的分析,有这样一个规律: 如果n是偶数,SG(n) = n / 2; 如果n是奇数,SG(n) = SG(n / 2); 这道题的意义不在于规律是什么,而是要自己能够写出求SG函数值的代码.顺便再体会一下mex(S)的含义. #include <cstring> ; int SG[maxn],…
问题 给一个数k,给出第k个回文数  链接 题解 打表找规律,详见https://www.cnblogs.com/lfri/p/10459982.html,差别仅在于这里从1数起. AC代码 #include<cstdio> #include<iostream> #include<string> #include<sstream> using namespace std; typedef long long LL; void solve(string str…
题目传送门 /* 找规律/数位DP:我做的时候差一点做出来了,只是不知道最后的 is_one () http://www.cnblogs.com/crazyapple/p/3315436.html 数位DP:http://blog.csdn.net/libin56842/article/details/11580497 */ #include <cstdio> #include <iostream> #include <algorithm> #include <c…
Minimum palindrome Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 260    Accepted Submission(s): 127 Problem Description Setting password is very important, especially when you have so many "in…
If we sum up every digit of a number and the result can be exactly divided by 10, we say this number is a good number. You are required to count the number of good numbers in the range from A to B, inclusive. InputThe first line has a number T (T <=…
题意:中文题,直接忽略... 析:先说说我的思路,我一看这个题第一感觉就是要找规律,要是挨着算,猴年马月都跑不完,更何况时间限制是0.25s,怎么找规律呢,我算了一下前10位,分别是8,1,1,3,1,1,4,1,1,3,然后我就觉得应该是113114循环再加一第一位是8,果然AC了. 然后结束后我看看了题解好像是算出来的,因为数很大又不是高精度,肯定是要找规律了,假设n有k位,分别从右往左a1,a2...ak,首先a1(也就是个位)肯定不是9(因为如果是9,那么n+1就有0了),所以呢n+1各…
M=1:aaaaaaaa…… M=2:DFS+manacher, 暴出N=1~25的最优解,找规律.N<=8的时候直接输出,N>8时,头两个字母一定是aa,剩下的以aababb循环,最后剩余<5全部补a,等于5补aabab. M=3:abcabcabcabc…… #include <cstdio> #include <cstring> using namespace std; const char str[] = "aababb"; int m…
http://acm.hdu.edu.cn/showproblem.php?pid=4731 就做了两道...也就这题还能发博客了...虽然也是水题 先暴力DFS打表找规律...发现4个一组循环节...尾部特殊判断....然后构造一下... #include <cstdio> #include <string> #include <cstdlib> #include <cstring> #include <iostream> #include &…
题目链接:https://vjudge.net/contest/237394#problem/E A palindrome is a word, number, or phrase that reads the same forwards as backwards. For example, the name “anna” is a palindrome. Numbers can also be palindromes (e.g. 151 or 753357). Additionally num…