C. Permute Digits dfs大模拟】的更多相关文章

http://codeforces.com/contest/915/problem/C 这题麻烦在前导0可以直接删除,比如 1001 100 应该输出11就好 我的做法是用dfs,每一位每一位的比较.在dfs的时候用一个char *指针指着b需要比较的位置,这样做方便很多. 2018年1月20日 16:35:51 身体好差,代码也很多不会写了.退役得真快. bigger需要在新的一行里面弄,因为函数传参的时候不确定是哪个先,哪个后的.再正规点,不要一行写两次,带有++, --的东西 也就是不要…
C. Permute Digits You are given two positive integer numbers a and b. Permute (change order) of the digits of a to construct maximal number not exceeding b. No number in input and/or output can start with the digit 0. It is allowed to leave a as it i…
You are given two positive integer numbers a and b. Permute (change order) of the digits of a to construct maximal number not exceeding b. No number in input and/or output can start with the digit 0. It is allowed to leave a as it is. Input The first…
题目链接:Permute Digits 题意: 给出了两个数字a,b(<=1e18),保证a,b都不带前缀0.用a的字符重组一个数字使这个值最大且小于b.(保证这个值存在) 题解: 这题遇到了不止一遍了,但是每次都会写错-所以感觉很有必要写下来.看到这题,我的第一想法是贪心每次都取最大的.但是这样其实存在很大的漏洞,因为字符个数是有限的如果小的数被取完了大的数填充进去也不符合条件.这题要按DFS的思路去做才行.这里给出按贪心的做法的一组错误数据. a: 123456789123456789 b:…
C. Permute Digits time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You are given two positive integer numbers a and b. Permute (change order) of the digits of a to construct maximal number n…
Read Phone Number Time Limit:1000MS     Memory Limit:64000KB     64bit IO Format:%lld & %llu Submit Status Practice ACdream 1188 Description Do you know how to read the phone numbers in English? Now let me tell you. For example, In China, the phone n…
[题目传送门] 1383 : The Book List 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 The history of Peking University Library is as long as the history of Peking University. It was build in 1898. At the end of year 2015, it had about 11,000 thousand volumes of books,…
题目描述 网上冲浪时,$Slavko$被冲到了水箱里,水箱由上而下竖直平面.示意图如下: 数字$i$所在的矩形代表一个编号为$i$的水箱.1号水箱为水箱中枢,有水管连出.除了$1$号水箱外,其他水箱上方会接进来恰好一条水管,也可能有水管连出.连出的水管会从水箱侧面连出去,同一个水箱连出去的水管会在不同的行与侧面连接.每一条水管直接连接两个水箱,这意味着不会把水管分叉也不会出现水管交叉的情况.这样,从一个水箱流入另外一个水箱时,水管的走向始终保持行号增加或保持不变.水会源源不断地涌进$1$号水箱直…
题目链接 题意:给定一个很大的数,把他们分为数个回文数的和,分的个数不超过50个,输出个数并输出每个数,special judge. 题解:现场赛的时候很快想出来了思路,把这个数从中间分为两部分,当位数为偶数的时候3456就分为34和56,34-1=33,回文数3333,3456-3333=123然后继续算:当位数为奇数的时候34567就分为34和67,5-1=4,回文数34443,34567-34443=124然后继续算.但是一年都没有写过高精度减法的题了,这个大模拟写了很久最后判断奇偶性都判…
题目描述 幻方是一种很神奇的N*N矩阵:它由数字1,2,3,……,N*N构成,且每行.每列及两条对角线上的数字之和都相同. 当N为奇数时,我们可以通过以下方法构建一个幻方: 首先将1写在第一行的中间. 之后,按如下方式从小到大依次填写每个数K(K=2,3,…,N*N): 1.若(K−1)在第一行但不在最后一列,则将K填在最后一行,(K−1)所在列的右一列: 2.若(K−1)在最后一列但不在第一行,则将K填在第一列,(K−1)所在行的上一行: 3.若(K−1)在第一行最后一列,则将K填在(K−1)…