CodeForces-915C Permute Digits】的更多相关文章

题目链接: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…
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…
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…
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] //从大到小枚举第i(1..len1)位 //剩余的数字从小到大排序. //看看组成的数字是不是小于等于b //如果是的话. //说明第i位就是选这个数字了. //接下来枚举下一位. [代码] #include <bits/stdc++.h> #define ll long long using namespace std; const int N = 20; string s1,s2; int len1,len2; int…
Problem D. Digits 题目连接: http://codeforces.com/gym/100531/attachments Description Little Petya likes integers. Recently he has learned about different properties of sums of number's digits. For example, if the sum of number's digits is divisible by 9,…
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…
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…
http://codeforces.com/contest/915/problem/C 这题麻烦在前导0可以直接删除,比如 1001 100 应该输出11就好 我的做法是用dfs,每一位每一位的比较.在dfs的时候用一个char *指针指着b需要比较的位置,这样做方便很多. 2018年1月20日 16:35:51 身体好差,代码也很多不会写了.退役得真快. bigger需要在新的一行里面弄,因为函数传参的时候不确定是哪个先,哪个后的.再正规点,不要一行写两次,带有++, --的东西 也就是不要…