codeforces 897B Chtholly's request 题目链接: http://codeforces.com/problemset/problem/897/B 思路: 暴力求出这100000个偶数回文数,说是暴力,其实是直接求出,O(n).然后累加求和取模即可.注意WA test 12是因为没有求导最后一个回文数,心痛啊,调了一个半小时最后没检查出来,一定要注意范围 代码: #include <iostream> #include <algorithm> #incl…
B. Chtholly's request time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output — Thanks a lot for today. — I experienced so many great things. — You gave me memories like dreams... But I have to le…
题目出处:http://codeforces.com/problemset/problem/897/B 题目大意:构造一个题意要求的zcy数之后取模 #include<iostream> using namespace std; int main(){ int n,m; __int64 g,t,sum=; cin>>n>>m; //关键在于zcy数的构造 //注意到要求长度是偶数 //考虑回文构造 ;i<=n;i++){ g=i; t=i; ){ g=g*+t%;…
Find the smallest prime palindrome greater than or equal to N. Recall that a number is prime if it's only divisors are 1 and itself, and it is greater than 1.  For example, 2,3,5,7,11 and 13 are primes. Recall that a number is a palindrome if it read…
U3346 A1-偶回文数 题目背景 方方方很喜欢回文数,于是zzq就出了一道关于回文数的题目. 因为偶回文数比较简单,所以方方方就把它放在了第一题... 题目描述 我们定义一个长度为偶数的回文数叫做偶回文数. 输入一个n(1<=n<=10^18),求从小到大第n个偶回文数. 输入输出格式 输入格式: 一行一个正整数n. 输出格式: 第n个偶回文数. 输入输出样例 输入样例#1: 233 输出样例#1: 233332 说明 1<=n<=10^18 思路:找规律. #include&…
题意:给一个数n,让你找出长度为偶数,并且是第 n 个回文数. 析:你多写几个就知道了,其实就是 n,然后再加上n的逆序,不过n有点大,直接用string 好了. 代码如下: #include <iostream> #include <cmath> #include <cstdlib> #include <set> #include <cstdio> #include <cstring> #include <algorithm&…
所谓回文字符串,就是正读和反读都一样的字符串,比如"level"或者"noon"等等就是回文串.即是对称结构 判断回文字符串 方法一: def is_palindrome(s): return True if s == s[::-1] else False 方法二: def is_palindrome(s): length = len(s) if not length: # 空字符串 return True mid_index = length // 2 # 如果s…
1.题目 如标题,求大于整数N(N>=0)的第一个回文数的字符串表示形式. 这个题目也是当时笔试第一次见到,花了一个小时才做出了.慢慢总结还是挺简单的. 2.分析 分析如下: (1)一位数N(9除外). 第一个大于N回文数等于N+1,如大于3的第一个回文数是4. (2)奇数位(一位数除外) 需要看“左边反转数字”是否大于"右边数字". 1)如果小于等于,则“左边+中间字母”组成的数字+1,再对称就可以. 2)如果大于,则左边数字直接对称到右边就可以啦. (3)偶数位 需要看“左边…
直接拿之前一次竞赛中写的code,稍微完善了点,后面有机会在优化 uint64_t GetNextPalindrome(uint64_t data) { //100以内的数字已经特殊考虑过,不存在差值1的两个回文数 //首先得到长度,如果是奇数,取前一半+中间值构造,如果是偶数,取前一半构造 //==================== //添加部分code,得到通用的获取下一个回文数的函数,记录到代码库里面,有需要时候直接拿来用 //函数功能是获取下一个回文数, //下面的是100意外的部分,…
Let's say a positive integer is a superpalindrome if it is a palindrome, and it is also the square of a palindrome. Now, given two positive integers L and R(represented as strings), return the number of superpalindromes in the inclusive range [L, R].…