【Codeforces Round #427 (Div. 2) B】The number on the board
【Link】:http://codeforces.com/contest/835
【Description】
原本有一个数字x,它的各个数码的和原本是>=k的;
现在这个数字x,在不改变位数的情况下,变成了n;
问你n和原来的数字x最少可能有多少位不一样.
(x是未知的)
【Solution】
如果各位大于等于k,直接输出0;
否则,先把n小的数码加到9;
一直加知道大于等于k;
【NumberOf WA】
0
【Reviw】
【Code】
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1e5;
int k,a[N+100],sum,now;
char s[N+100];
main(){
scanf("%lld",&k);
scanf("%s",s+1);
int len = strlen(s+1);
for (int i = 1;i <= len;i++)
a[i] = s[i]-'0',sum+=a[i];
sort(a+1,a+1+len);
now = 0;
while (sum < k){
now++;
sum+=(9-a[now]);
}
printf("%lld\n",now);
return 0;
}
【Codeforces Round #427 (Div. 2) B】The number on the board的更多相关文章
- 【Codeforces Round #427 (Div. 2) D】Palindromic characteristics
[Link]:http://codeforces.com/contest/835/problem/D [Description] 给你一个字符串; 让你在其中找到1..k阶的回文子串; 并统计它们的数 ...
- 【Codeforces Round #427 (Div. 2) A】Key races
[Link]:http://codeforces.com/contest/835/problem/A [Description] [Solution] 傻逼题. [NumberOf WA] [Revi ...
- 【Codeforces Round #427 (Div. 2) C】Star sky
[Link]:http://codeforces.com/contest/835/problem/C [Description] 给你n个星星的坐标(xi,yi); 第i个星星在第t秒,闪烁值变为(s ...
- 【Codeforces Round #460 (Div. 2) B】 Perfect Number
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 直接暴力求出第k个perfect数字就好. 纯模拟. [代码] #include <bits/stdc++.h> #de ...
- Codeforces Round #427 (Div. 2) Problem B The number on the board (Codeforces 835B) - 贪心
Some natural number was written on the board. Its sum of digits was not less than k. But you were di ...
- 【Codeforces Round #432 (Div. 1) B】Arpa and a list of numbers
[链接]h在这里写链接 [题意] 定义bad list是一个非空的.最大公约数为1的序列.给定一个序列,有两种操作:花费x将一个元素删除.花费y将一个元素加1,问你将这个序列变为good list所需 ...
- 【Codeforces Round #420 (Div. 2) C】Okabe and Boxes
[题目链接]:http://codeforces.com/contest/821/problem/C [题意] 给你2*n个操作; 包括把1..n中的某一个数压入栈顶,以及把栈顶元素弹出; 保证压入和 ...
- 【Codeforces Round #420 (Div. 2) B】Okabe and Banana Trees
[题目链接]:http://codeforces.com/contest/821/problem/B [题意] 当(x,y)这个坐标中,x和y都为整数的时候; 这个坐标上会有x+y根香蕉; 然后给你一 ...
- 【Codeforces Round #420 (Div. 2) A】Okabe and Future Gadget Laboratory
[题目链接]:http://codeforces.com/contest/821/problem/A [题意] 给你一个n*n的数组; 然后问你,是不是每个位置(x,y); 都能找到一个同一行的元素q ...
随机推荐
- 题解 P3372 【【模板】线段树 1】(珂朵莉树解法)
这道题可以用珂朵莉树做,但是由于数据比较不随机,而我也没有手写一颗平衡树,所以就被卡掉了,只拿了70分. 珂朵莉树是一种基于平衡树的(伪)高效数据结构. 它的核心操作是推平一段区间. 简而言之,就是把 ...
- centos7 安装rsyslog
http://blog.csdn.net/u011630575/article/details/50896781 http://blog.chinaunix.net/uid-21142030-id-5 ...
- 有关于OpenGL、OpenGL ES、WebGL的小结
转自原文 有关于OpenGL.OpenGL ES.WebGL的小结 一. OpenGL简介 OpenGL(全写Open Graphics Library)是个定义了一个跨编程语言.跨平台的编程接口 ...
- ArcGIS api for javascript——查找任务-没有地图查找要素
描述 本例展示了如何使用查找任务搜索数据里的记录,然后在HTML表格中显示结果. 尽管FindTask不需要显示一个地图,但是构造函数需要一个ArcGIS Server地图服务的URL. 本例使用ES ...
- java 究竟老年代和年轻代的比例为多大合适呢?
眼下我还没有这方面过多的经验,和切身体会 只是以我眼下的水平看来,年轻代不宜大,假设年轻代大会导致转为老年代的时候,老年代撑不下.导致full gc.回收停顿时间过长
- C语言之基本算法26—佩尔方程求解
//穷举法! /* ====================================================== 题目:求佩尔方程x*x-73*y*y=1的解. =========== ...
- Please ensure that adb is correctly located at 'D:\Android\android-sdk\platform-tools\adb.exe' and
1.启动任务管理器 2.找到百度安全组件杀掉进程. 3.一般都是组件给禁止了.
- vue28-2.0-过滤器
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- Xamarin大佬的地址
https://www.cnblogs.com/hlx-blogs/p/7266098.html http://www.cnblogs.com/GuZhenYin/p/6971069.html
- BZOJ 2836 树链剖分+线段树
思路: 链剖+线段树裸题 重链的标号就是DFS序 所以查子树的时候每回就 query(change[x],change[x]+size[x]-1) 就好了 剩下的应该都会吧.. //By Sirius ...