SUBSTRING 时间限制: 1 Sec  内存限制: 128 MB 提交: 17  解决: 5 [提交][状态][讨论版] 题目描述 You are given a string input. You are to find the longest substring of input such that the reversal of the substring is also a substring of input. In case of a tie, return the strin…
序号互换 时间限制: 1 Sec  内存限制: 128 MB 提交: 41  解决: 19 [提交][状态][讨论版] 题目描述 Dr.Kong设计了一个聪明的机器人卡多,卡多会对电子表格中的单元格坐标快速计算出来.单元格的行坐标是由数字编号的数字序号,而列坐标使用字母序号.观察字母序号,发现第1列到第26列的字母序号分别为A,B,-,Z,接着,第27列序号为AA,第28列为AB,依此类推. 若给Dr.Kong的机器人卡多一个数字序号(比如32),它能很快算出等价的字母序号(即AF),若给机器人…
表达式求值 时间限制: 1 Sec  内存限制: 128 MB 提交: 14  解决: 7 [提交][状态][讨论版] 题目描述 Dr.Kong设计的机器人卡多掌握了加减法运算以后,最近又学会了一些简单的函数求值,比如,它知道函数min(20,23)的值是20 ,add(10,98) 的值是108等等.经过训练,Dr.Kong设计的机器人卡多甚至会计算一种嵌套的更复杂的表达式. 假设表达式可以简单定义为: 1. 一个正的十进制数 x 是一个表达式. 2. 如果 x 和 y 是 表达式,则 函数m…
1001: 节 能 时间限制: 1 Sec  内存限制: 128 MB 提交: 21  解决: 9 [提交][状态][讨论版] 题目描述 Dr.Kong设计的机器人卡多越来越聪明.最近市政公司交给卡多一项任务,每天早晨5:00开始,它负责关掉ZK大道右侧上所有的路灯. 卡多每到早晨5:00准会在ZK大道上某盏路灯的旁边,然后他开始关灯.每盏灯都有一定的功率,机器人卡多有着自觉的节能意识,它希望在关灯期间,ZK大道右侧上所有路灯的耗电量总数是最少的. 机器人卡多以1m/s的速度行走.假设关灯动作不…
相似与27进制的转换 #include<iostream> #include<cstdio> #include<cstring> #include<string> #include<cstdlib> #include<algorithm> #include<stack> using namespace std; int main(){ int t; string s; cin>>t; while(t--) {…
栈的模拟应用: #include<iostream> #include<cstdio> #include<cstring> #include<string> #include<cstdlib> #include<algorithm> #include<stack> using namespace std; string getPostfixExp(string s) { stack<char> sta;// d…
substr(start,length)第一个参数是开始位置(注:start的开始是从0开始,看到好多博客上面是从1开始,在火狐和谷歌执行了一下是从0开始),第二个参数是截取字符串的长度(可以省略,表示到字符串末尾). 例如: var ver = ",6200,6300,6400,"; var first = ver.substr(0,1); //获取第一个字符"," var last = ver.substr(-1,1); //获取最后的一个",&quo…
需求:Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic substring. 如果一个字符串从左向右写和从右向左写是一样的,这样的字符串就叫做palindromic string 判断回文数,中间开花.定一个中心,向两边散…
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2017 思路:思考字符串和数字的本质区别是什么. 今天先是试着做了一个完全背包的题目,发现自己还是不会做,弄了几个小时还是不会,眼看就要到11点,于是就挑了一个简单的题目来放松哈心情. 结论就是,自己的基础太薄弱了.看到这个简单的题目自己还是Google了一下,才知道如何做. 希望自己国庆这几天能好好把落下的课程好好补一下. 查阅的收获: 本题可以通过 if (c=='\n') break; a[i] !…
表达式求值 时间限制:1000 ms | 内存限制:65535 KB 难度:3   描述 假设表达式定义为:1. 一个十进制的正整数 X 是一个表达式.2. 如果 X 和 Y 是 表达式,则 X+Y, X*Y 也是表达式; *优先级高于+.3. 如果 X 和 Y 是 表达式,则 函数 Smax(X,Y)也是表达式,其值为:先分别求出 X ,Y值的各位数字之和,再从中选最大数.4.如果 X 是 表达式,则 (X)也是表达式. 例如:表达式 12*(2+3)+Smax(333,220+280) 的值…
随机字符串 题目描述 起名字什么的最麻烦,我们来生成一些随机字符串吧 生成的字符串当然是有要求的: .长度不能超过n .字符串中仅包含大写字母 .生成的字符串必须包含字符串“ACM” ok,是不是很简单?现在告诉你n的值,你来告诉我这样的字符串有多少个 输入 输入一个正整数T,代表有T组数据 接下来T行,每行一个正整数n,n<=. 输出 输出符合条件的字符串的数目 样例输入 样例输出 题解: using namespace std; #define inf 0x3f3f3f3f #define…
数制转换分数: 2 时间限制:1 秒 内存限制:32 兆 特殊判题: 否 提交:59 解决: 24 标签 进制转换 题目描述 求任意两个不同进制非负整数的转换(2进制-16进制),所给整数在long所能表达的范围之内.不同进制的表示符号为(0,1,...,9,a,b,...,f)或者(0,1,...,9,A,B,...,F). 输入格式 输入只有一行,包含三个整数a,n,b.a表示其后的n 是a进制整数,b表示欲将a进制整数n转换成b进制整数.a,b是十进制整数,2 =< a,b <= 16.…
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=168 分析:找到一天中需要最多的房间即可 #include<iostream> #include<cstdio> #include<algorithm> #include<cstring> using namespace std; #define N 200 int day[N];//day[i] 第i天的最多房间数 int main() { fre…
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=251 规则: 1.若某竞标价唯一,则胜出 2.若不存在唯一竞标价,则投标次数最少竞标价中标,存在多个时,选择价钱最低且最先投此价钱的为中标 #include<iostream> #include<cstdio> #include<cstring> using namespace std; #define N 102 #define M 1002 struct N…
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=170 根据题意,需要找到度数为1的结点个数,如下图: #include<iostream> #include<cstdio> #include<cstring> #include<vector> using namespace std; #define N 10002 vector<int> g[N]; int main() { freo…
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=171 动态规划: d(i,j) = max{d(i-1, j), d(i, j-1)}+mp[i][j]; #include<iostream> #include<cstdio> #include<cstring> #include<string> #include<algorithm> using namespace std; #def…
原文链接http://www.cnblogs.com/zhouzhendong/p/8982392.html 题目传送门 - SPOJ LCS 题意 求两个字符串的最长公共连续子串长度. 字符串长$\leq 250000$ 题解 首先对于第一个字符串建一个$SAM$. 然后拿第二个串在$SAM$上面走一遍就好了. 具体地: 将第二个串的字符一个一个地按照顺序加入. 设当前状态为$now$,要加入字符$c$,当前匹配的字符串长度为$len$(答案自然是各种情况下$len$的最大值). 如果在$SA…
SELECT a1,a2,replace(a2, "豫ICP备16006180号-", "") a22,a3,a4,a5 FROM `aaab` order by a2;SELECT a1,a2,substring(a2, 22) a22,a3,a4,a5 FROM `aaab` order by a22;…
#include<iostream> #include<cstdio> #include<algorithm> #include<cstring> using namespace std; #define N 352 /* 重量*单价+重量*距离 = 重量*(距离+单价) 预处理单价 贪心:优先买价格低的 */ struct Node { int p;// p = (单价+距离) int w; }c[N]; bool cmp(Node a, Node b)…
#include <iostream> #include <cstdio> #include <queue> #include <cstring> #include <algorithm> #include <cmath> using namespace std; #define N 1100 #define INF 0x7fffffff bool prime[N]; void init() { memset(prime, true,…
题目思路:使用二分查找路径中最大值和最小值之间的差值,从而确定出一组minn和maxn,对此组的minn和maxn经行DFS,如果可以找到一条路径,其中的最大值,最小值在minn~maxn的范围内,则查找成功.继续向左查找,否则向右查找 #include<iostream> #include<algorithm> #include<cstring> #include<vector> #include<stdio.h> #include<qu…
题目的意思是给你一个机器人,初始的时候在某一个给定的路灯位置,机器人要把路边所有的路灯关掉,每个路灯都有一个距离和一个功率,求要把所有的路灯关掉最小的最终能耗是多少? 题目是一个很明显的区间DP.可以这样考虑,机器人关掉一个区间的路灯后,一定停留在该区间的最左端或者最右端,而且必须包括起点,显然. 这样我们就可以区间dp了. 对于每一个含有初始位置的区间[i,j],只有两种位置使其最终的位置为j,那就是i和j-1.这样就得到了状态转移了. 接下来还有一个问题,就是怎么计算能耗呢?这样想,对于每个…
H. 最小内积                                                                   Time Limit: 1000ms Memory Limit: 65536KB 64-bit integer IO format: %lld      Java class name: Main 向量是几何中的一个重要概念. 考虑两个向量 v1=(x1,x2,...,xn)和v2=(y1,y2,...,yn),向量的内积定义为 x1y1+x2y2+…
A. Nearly Lucky Number time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations con…
D. Animals time limit per test 2 seconds memory limit per test 64 megabytes input input.txt output output.txt Once upon a time DravDe, an outstanding person famous for his professional achievements (as you must remember, he works in a warehouse stori…
C. Primes on Interval time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You've decided to carry out a survey in the theory of prime numbers. Let us remind you that a prime number is a positiv…
A. Boy or Girl time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Description Those days, many boys use beautiful girls' photos as avatars in forums. So it is pretty hard to tell the gender of…
B. Easy Number Challenge time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Let's denote d(n) as the number of divisors of a positive integer n. You are given three integers a, b and c. Your…
表达式求值 时间限制:3000 ms  |  内存限制:65535 KB 难度:3   描述 Dr.Kong设计的机器人卡多掌握了加减法运算以后,最近又学会了一些简单的函数求值,比如,它知道函数min(20,23)的值是20 ,add(10,98) 的值是108等等.经过训练,Dr.Kong设计的机器人卡多甚至会计算一种嵌套的更复杂的表达式. 假设表达式可以简单定义为: 1. 一个正的十进制数 x 是一个表达式. 2. 如果 x 和 y 是 表达式,则 函数min(x,y )也是表达式,其值为x…
表达式求值时间限制:3000 ms  |  内存限制:65535 KB 难度:3描述 Dr.Kong设计的机器人卡多掌握了加减法运算以后,最近又学会了一些简单的函数求值,比如,它知道函数min(20,23)的值是20 ,add(10,98) 的值是108等等.经过训练,Dr.Kong设计的机器人卡多甚至会计算一种嵌套的更复杂的表达式. 假设表达式可以简单定义为: 1. 一个正的十进制数 x 是一个表达式. 2. 如果 x 和 y 是 表达式,则 函数min(x,y )也是表达式,其值为x,y 中…