cf#513 B. Maximum Sum of Digits】的更多相关文章

B. Maximum Sum of Digits time limit per test 2 seconds memory limit per test 512 megabytes input standard input output standard output You are given a positive integer nn. Let S(x)S(x) be sum of digits in base 10 representation of xx, for example, S(…
Maximum Sum of Digits You are given a positive integer n. Let S(x)S(x) be sum of digits in base 10 representation of xx , for example, S(123)=1+2+3=6S(123)=1+2+3=6 , S(0)=0S(0)=0 . Your task is to find two integers a,ba,b , such that 0≤a,b≤n0≤a,b≤n ,…
Description You are given a positive integer nn. Let S(x) be sum of digits in base 10 representation of xx, for example, S(123)=1+2+3=6, S(0)=0. Your task is to find two integers a,ba,b, such that 0≤a,b≤n, a+b=n and S(a)+S(b) is the largest possible…
我对贪心的理解:https://www.cnblogs.com/AKMer/p/9776293.html 题目传送门:http://codeforces.com/problemset/problem/1060/B 显然贪一点能怼出\(9\)就往死里怼嘛--然后就直接算就行了. 时间复杂度:\(O(len)\) 空间复杂度:\(O(1)\) 代码如下: #include <cstdio> using namespace std; #define ll long long ll a,b; ll r…
http://codeforces.com/contest/1060/problem/B 题意:将n拆为a和b,让a+b=n且S(a)+S(b)最大,求最大的S(a)+S(b). 思路:考虑任意一个数,例如156,将其分为:但是当分为 :将其分为 .S(a)+S(b)是如何变大的?考虑b任意一个数位,当其从0变为9,S(a)增大1,S(B)增大8:当是其它情况时(数位变化不跨越0),相当于S(a)+x, S(b)-x,S(a)+S(b)不变.总结起来,划分(a,b)时让尽量多的数位变化能够跨越0…
C. Little Girl and Maximum Sum time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output The little girl loves the problems on array queries very much. One day she came across a rather well-known proble…
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…