C. Given Length and Sum of Digits... time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the la…
Given Length and Sum of Digits... 题目链接: http://acm.hust.edu.cn/vjudge/contest/121332#problem/F Description You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m…
题目链接:http://codeforces.com/problemset/problem/489/C 题目意思:给出 m 和 s,需要构造最大和最小的数.满足长度都为 m,每一位的数字之和等于 s.如果构造不出来,输出 -1 -1.否则输出最小和最大且符合条件的数. 想了两个多小时,发现想错了方向...... /****************************************** 首先把不能得到最小数和最大数的情况揪出来. 第二组测试数据 3 0 有提示,s = 0 且 m >…
m位长度,S为各位的和 利用贪心的思想逐位判断过去即可 详细的注释已经在代码里啦~ //#pragma comment(linker, "/STACK:16777216") //for c++ Compiler #include <stdio.h> #include <iostream> #include <cstring> #include <cmath> #include <stack> #include <queu…
Sum It Up Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Description Given a specified total t and a list of n integers, find all distinct sums using numbers from the list that add up to t. For example, if…
题目链接:Permute Digits 题意: 给出了两个数字a,b(<=1e18),保证a,b都不带前缀0.用a的字符重组一个数字使这个值最大且小于b.(保证这个值存在) 题解: 这题遇到了不止一遍了,但是每次都会写错-所以感觉很有必要写下来.看到这题,我的第一想法是贪心每次都取最大的.但是这样其实存在很大的漏洞,因为字符个数是有限的如果小的数被取完了大的数填充进去也不符合条件.这题要按DFS的思路去做才行.这里给出按贪心的做法的一组错误数据. a: 123456789123456789 b:…
题目链接:http://poj.org/problem?id=1564 题目大意:给定一个整数t,和n个元素组成的集合.求能否用该集合中的元素和表示该整数,如果可以输出所有可行解.1<=n<=12 Sample Input 4 6 4 3 2 2 1 1 5 3 2 1 1 400 12 50 50 50 50 50 50 25 25 25 25 25 25 0 0 Sample Output Sums of 4: 4 3+1 2+2 2+1+1 Sums of 5: NONE Sums of…
Sum It Up Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 2982    Accepted Submission(s): 1493 Problem Description Given a specified total t and a list of n integers, find all distinct sums usin…
Sum It Up Problem Description Given a specified total t and a list of n integers, find all distinct sums using numbers from the list that add up to t. For example, if t=4, n=6, and the list is [4,3,2,2,1,1], then there are four different sums that eq…
题目链接:http://poj.org/problem?id=1564 给出m个数,求出和为n的组合方式:并按从大到小的顺序输出: 简单的dfs但是看了代码才会: #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; int n, m, flag; ], b[]; int cmp(int a, int b) { re…