D - Ugly Problem HDU - 5920】的更多相关文章

D - Ugly Problem HDU - 5920 Everyone hates ugly problems. You are given a positive integer. You must represent that number by sum of palindromic numbers. A palindromic number is a positive integer such that if you write out that integer as a string i…
Ugly Problem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 0    Accepted Submission(s): 0Special Judge Problem Description Everyone hates ugly problems.You are given a positive integer. You mu…
题目链接: Ugly Problem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 363    Accepted Submission(s): 134Special Judge Problem Description Everyone hates ugly problems.You are given a positive integ…
Ugly Problem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Special Judge Problem Description Everyone hates ugly problems. You are given a positive integer. You must represent that number by sum of palindromic num…
Ugly Problem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 190    Accepted Submission(s): 74Special Judge Problem Description Everyone hates ugly problems. You are given a positive integer. Yo…
Flow Problem HDU - 3549 Network flow is a well-known difficult problem for ACMers. Given a graph, your task is to find out the maximum flow for the weighted directed graph.  InputThe first line of input contains an integer T, denoting the number of t…
Prime Ring Problem HDU - 1016 A ring is compose of n circles as shown in diagram. Put natural number 1, 2, ..., n into each circle separately, and the sum of numbers in two adjacent circles should be a prime. Note: the number of first circle should a…
http://acm.hdu.edu.cn/showproblem.php?pid=5920 http://www.cnblogs.com/xudong-bupt/p/4015226.html 把前半部分复制过去,如果太大,那么早到第一个会使得其太大的点,减1,然后对应的中间的变成9 #include <iostream> #include <cstdio> #include <cstring> #include <cmath> #include <a…
说起这道题, 真是一把辛酸泪. 题意 将一个正整数 \(n(\le 10^{1000})\) 分解成不超过50个回文数的和. 做法 构造. 队友UHC提出的一种构造方法, 写起来比较方便一些, 而且比较巧妙. 可惜我码力太弱, 现场没调出来. 大体的想法是: 将一个数"等"分成两半. 如果长度为奇数可以采取下面两种处理方法之一. 在开头补0. 后一半 (低位) 的长度向下取整. 我采取第2种处理方式. 设前一半的长度为\(h_1\), 后一半的长度为 \(h_2\). 然后将前一半长…
题目链接 题意:给定一个很大的数,把他们分为数个回文数的和,分的个数不超过50个,输出个数并输出每个数,special judge. 题解:现场赛的时候很快想出来了思路,把这个数从中间分为两部分,当位数为偶数的时候3456就分为34和56,34-1=33,回文数3333,3456-3333=123然后继续算:当位数为奇数的时候34567就分为34和67,5-1=4,回文数34443,34567-34443=124然后继续算.但是一年都没有写过高精度减法的题了,这个大模拟写了很久最后判断奇偶性都判…
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=5920 我们的思路是: 对于一个串s,先根据s串前一半复制到后一半构成一个回文串, 如果这个回文串比s小,则做减法并递归: 如果相等直接结束: 如果大,那么找前一半离中心最近的一个非零数减1,并把这位之后到中心的数全都变为9,例如11000->11011,大了,所以变成10901: ps:因为大数相减要传指针参数,调了蛮久,发现指针的乱指了,所以开了一个二维数组,每一次算出的原串和回文串都用新的指针,也…
链接: http://acm.hdu.edu.cn/showproblem.php?pid=5443 The Water Problem Time Limit: 1500/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 738    Accepted Submission(s): 591 Problem Description In Land waterless, w…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5105 题目意思:给出一个6个实数:a, b, c, d, l, r.通过在[l, r]中取数 x,使得这个函数 f(x)= |a∗x3+b∗x2+c∗x+d| 最大. 我一开始做的时候,很天真的认为数据量这么小,一个一个试,暴力搜就肯定能得到答案啦.但是一个很严重的问题是,x 没有说是实数还是整数,所以枚举根本不可行. 于是就联想到应该使用高中求一元三次方程的方法来做.我当时是直接从 f(l), f…
String Problem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1492    Accepted Submission(s): 662 Problem Description Give you a string with length N, you can generate N strings by left shifts.…
River Problem Time Limit: 6000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 721    Accepted Submission(s): 282 Problem Description The River of Bitland is now heavily polluted. To solve this problem, the King…
链接: http://acm.hdu.edu.cn/contests/contest_showproblem.php?pid=1005&cid=595 若一个整数的个位数字截去,再从余下的数中,减去个位数的2倍,如果差是7的倍数,则原数能被7整除.如果一次不容易看出,就需要继续上述过程.如6139,过程如下:613-9×2=595,59-5×2=49,所以6139是7的倍数. 能被11整除的数的特征把一个数由右边向左边数,将奇位上的数字与偶位上的数字分别加起来,再求它们的差,如果这个差是11的倍…
题目链接:https://cn.vjudge.net/contest/276233#problem/H 题目大意:对于给定的矩阵  每一行除以ai  每一列除以bi 之后 数组的所有元素都还在那个L-R范围之内,a[i]和b[j]是不知道的,然后问你是否有这样的数组a和数组b满足条件. 具体思路:我们可以写出这样的等式, L<=Map[i][j]*a[i]/b[j]<=R, 然后继续化简 L/Map[i][j]<=a[i]/b[j]<=R/Map[i][j], 然后两边同时取log…
Wool Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Problem Description At dawn, Venus sets a second task for Psyche. She is to cross a river and fetch golden wool from violent sheep who graze on the other side.…
题意:给出一个数字串,询问最长的子串,满足以下要求:将子串平均分为三部分,一三部分相等,一二部分对衬. /* 在manachar的基础上,枚举回文串的中心,再找第三部分. */ #include<cstdio> #include<iostream> #define M 200010 using namespace std; int s[M],a[M],p[M],len; void Manancher(){ ; a[l++]=-; a[l++]=-; ;i<len;i++){…
题目大意:有一个字符串长度为N的字符串,这个字符串可以扩展出N个字符串,并且按照顺序编号,比如串  ” SKYLONG “ SKYLONG 1 KYLONGS 2 YLONGSK 3 LONGSKY 4 ONGSKYL 5 NGSKYLO 6 GSKYLON 7 下面这7个都是原串的扩展(循环位移),现在需要求出来字典序最小的和字典序最大的那个串的标号.   输出说明:最小字典序的编号,最小字典序个数,最大字典序编号,最大字典序个数.   分析:以前也遇到过类似的求最小字典序的问题,不过当时不会…
在一个王国里面, 国王有一个新的问题. 皇城中有N个城市M条单行路,为了让他的王国更加高效,国王想要将他的王国划分成几个州,每个城市必须属于一个州.对于两个城市(u,v),必须满足以下3个条件:   1.如果有一条从u到v的路,也有一条从v到u的路,那么u.v必须属于同一个州:   2.对于每一个州里的任何两个城市u.v,至少要有一方能到达另一方(必须经过同一个州的点到达).   3.一个城市只能属于一个州. 现在国王想要知道他的王国最少可以划分成多少个州. Input 第一行是一个数字T,代表…
A ring is compose of n circles as shown in diagram. Put natural number 1, 2, ..., n into each circle separately, and the sum of numbers in two adjacent circles should be a prime. Note: the number of first circle should always be 1.   Inputn (0 < n <…
题意: 给出一个字符串,问这个字符串经过移动后的字典序最小的字符串的首字符位置和字典序最大的字符串的首字符的位置,和能出现多少次最小字典序的字符串和最大字典序的字符串 解析: 能出现多少次就是求整个字符串能出现几次循环 然后就是最大最小表示法..有点厉害... #include <iostream> #include <cstdio> #include <sstream> #include <cstring> #include <map> #in…
描述 给定一个序列A[0],A[1],…A[N-1],要求找到p0,p1,p2,p3使得A[p0]+A[p0+1]+…+A[p1] + A[p2]+A[p2+1]+…+A[p3]最大(0<=p0<=p1<p2<=p3<N).你只需要求出这个最大值就可以. 输入 输入的第一行为一个数N(2<=N<=10000),接下来的一行为N个整数(-100<A[i]<100). 输出 输出一个整数表示最大值. 样例输入 5-1 -2 -4 -5 4 样例输出 3 题…
Geometry Problem HDU - 6242 Alice is interesting in computation geometry problem recently. She found a interesting problem and solved it easily. Now she will give this problem to you : You are given NN distinct points (Xi,Yi)(Xi,Yi) on the two-dimens…
Ugly Problem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 0    Accepted Submission(s): 0Special Judge Problem Description Everyone hates ugly problems. You are given a positive integer. You m…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5652 题目大意:n*m的矩阵上,0为平原,1为山.q个询问,第i个询问给定坐标xi,yi,表示i年后这里的平原上会长出山.问第几年以后印度和中国交流会被阻碍 思路:(官方题解)这是一个连通性的问题.你会发现如果将所有操作逆序来看的话就很容易用并查集来处理了. 首先把所有的山峰都加到图中,然后逆序处理每个操作: 对某次操作,在图中删除该位置的山峰,然后判断两个点是否联通,一旦联通就得到了结果. 这里需…
传送门:hdu 5898 odd-even number 思路:数位DP,套着数位DP的模板搞一发就可以了不过要注意前导0的处理,dp[pos][pre][status][ze] pos:当前处理的位 pre:上一位的奇偶性 status:截止到上一位的连续段的奇偶性 ze:是否有前导0 /************************************************************** Problem:hdu 5898 odd-even number User: yo…
传送门:HDU 5895 Mathematician QSC 这是一篇很好的题解,我想讲的他基本都讲了http://blog.csdn.net/queuelovestack/article/details/52577212 [分析]一开始想简单了,对于a^x mod p这种形式的直接用欧拉定理的数论定理降幂了 结果可想而知,肯定错,因为题目并没有保证gcd(x,s+1)=1,而欧拉定理的数论定理是明确规定的 所以得另谋出路 那么网上提供了一种指数循环节降幂的方法 具体证明可以自行从网上找一找 有…
传送门:hdu 5894 hannnnah_j’s Biological Test 题目大意:n个座位,m个学生,使每个学生的间隔至少为k个座位 组合中的插空法 思路:每个学生先去掉k个空位间隔,剩下n-k*m:这些空位至少要坐m个学生,n-k*m-1个空,插m-1个门,方法数为:c(n-k*m-1,m-1):当只有一个学生时,间隔K个位的条件就没必要了,也就是n>k+1的条件不一定要成立 顺带弄了个Lucas的模板 /**************************************…