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 and sum of digits s. The required numbers should be non-negative integers written in the decimal base with…
http://codeforces.com/problemset/problem/489/C 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 …
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…
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…
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…
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…
题意: 找出m位且各个数位数字之和为s的最大和最小整数,不包括前导0(比如说003是非法的),但0是可以的. 分析: 这题是用贪心来做的,同样是m位数,前面的数字越大这个数就越大. 所以写一个can(int m, int s)函数,来判断是否存在一个m位数其各位数字之和为s 这里先不考虑前导0的事,代码看起来可能是这个样子的: bool can(int m, int s) { && s <= m*); } 比如我们现在要求满足要求的最小整数,从最左边的数开始从0到9开始试,如果后面的…