C. Really Big Numbers
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

Ivan likes to learn different things about numbers, but he is especially interested in really big numbers. Ivan thinks that a positive integer number x is really big if the difference between x and the sum of its digits (in decimal representation) is not less than s. To prove that these numbers may have different special properties, he wants to know how rare (or not rare) they are — in fact, he needs to calculate the quantity of really big numbers that are not greater than n.

Ivan tried to do the calculations himself, but soon realized that it's too difficult for him. So he asked you to help him in calculations.

Input

The first (and the only) line contains two integers n and s (1 ≤ n, s ≤ 1018).

Output

Print one integer — the quantity of really big numbers that are not greater than n.

Examples
Input
12 1
Output
3
Input
25 20
Output
0
Input
10 9
Output
1
Note

In the first example numbers 10, 11 and 12 are really big.

In the second example there are no really big numbers that are not greater than 25 (in fact, the first really big number is 30: 30 - 3 ≥ 20).

In the third example 10 is the only really big number (10 - 1 ≥ 9).

题意:找出1-n内所有数字,数字要满足的条件:数字-每位数的和>=s;

思路:每位数的和最多180,所有只需要暴力s,s+180区间,后面小于n的肯定满足条件;

#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<queue>
#include<algorithm>
#include<stack>
#include<cstring>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<bitset>
#include<time.h>
using namespace std;
#define LL long long
#define pi (4*atan(1.0))
#define eps 1e-4
#define bug(x) cout<<"bug"<<x<<endl;
const int N=3e5+,M=1e5+,inf=,mod=1e9+;
const LL INF=1e18+,MOD=1e9+; LL sum(LL x)
{
if(x==)return ;
return sum(x/)+x%;
}
int main()
{
LL n,s;
scanf("%lld%lld",&n,&s);
LL x=min(n,s);
LL ans=;
for(LL i=s;i<=s+;i++)
{
if(i<=n&&i-sum(i)>=s)
ans++;
}
ans+=max(0LL,n-s-);
printf("%lld\n",ans);
return ;
}

Educational Codeforces Round 23 C. Really Big Numbers 暴力的更多相关文章

  1. Educational Codeforces Round 23 E. Choosing The Commander trie数

    E. Choosing The Commander time limit per test 2 seconds memory limit per test 256 megabytes input st ...

  2. Educational Codeforces Round 13 A. Johny Likes Numbers 水题

    A. Johny Likes Numbers 题目连接: http://www.codeforces.com/contest/678/problem/A Description Johny likes ...

  3. Educational Codeforces Round 23.C

    C. Really Big Numbers time limit per test 1 second memory limit per test 256 megabytes input standar ...

  4. Educational Codeforces Round 23 B. Makes And The Product

    B. Makes And The Product time limit per test 2 seconds memory limit per test 256 megabytes input sta ...

  5. Educational Codeforces Round 23 F. MEX Queries 离散化+线段树

    F. MEX Queries time limit per test 2 seconds memory limit per test 256 megabytes input standard inpu ...

  6. Educational Codeforces Round 23 A-F 补题

    A Treasure Hunt 注意负数和0的特殊处理.. 水题.. 然而又被Hack了 吗的智障 #include<bits/stdc++.h> using namespace std; ...

  7. Educational Codeforces Round 23 D. Imbalanced Array 单调栈

    D. Imbalanced Array time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  8. Educational Codeforces Round 23 补题小结

    昨晚听说有教做人场,去补了下玩. 大概我的水平能做个5/6的样子? (不会二进制Trie啊,我真菜) A. 傻逼题.大概可以看成向量加法,判断下就好了. #include<iostream> ...

  9. Educational Codeforces Round 23

    A题 分析:注意两个点之间的倍数差,若为偶数则为YES,否则为NO #include "iostream" #include "cstdio" #include ...

随机推荐

  1. Python+OpenCV图像处理(十)—— 图像二值化

    简介:图像二值化就是将图像上的像素点的灰度值设置为0或255,也就是将整个图像呈现出明显的黑白效果的过程. 一.普通图像二值化 代码如下: import cv2 as cv import numpy ...

  2. zabbix 监控项(key)

    Key 描述 返回值 参数 详细说明 agent.hostname 返回被监控端名称 字符串 - 返回配置文件中配置的被监控端的名称 agent.ping 检测被监控端是否存活 1 - 运行中 其他 ...

  3. OSI七层详解

    OSI 七层模型通过七个层次化的结构模型使不同的系统不同的网络之间实现可靠的通讯,因此其最主要的功能就是帮助不同类型的主机实现数据传输 . 完成中继功能的节点通常称为中继系统.在OSI七层模型中,处于 ...

  4. LoggerFactory.getLogger用法

    使用指定类初始化日志对象,在日志输出的时候,可以打印出日志信息所在类 如:Logger logger = LoggerFactory.getLogger(com.lz.Test.class);     ...

  5. mean shift 图像分割(一、二、三)

    https://blog.csdn.net/u011511601/article/details/72843247 MeanShift图像分割算法:大概是将复杂的背景,通过粗化提取整体信息,进而将图像 ...

  6. 【react开发】使用swiper插件,loop:true时产生的问题解决方案

    这2天上班遇到的问题:react使用swiper3插件实现banner轮播,其中有个banner图有个click点击事件,而其他的是页面跳转.出现了一个问题: 就是向右滑动到该帧时的swiper,点击 ...

  7. 使用v-for指令渲染列表

    v-for:对集合或对象进行遍历: 使用v-for对数组遍历时: 效果如下: 代码: <script> window.onload= () =>{new Vue({ el:'#two ...

  8. PyCharm笔记之搭建Python开发环境

    新建一个空helloworld项目,然后新建一个main.py文件: 此时还无法运行,因为没有配置项目的入口脚本,通过下图的步骤指定一个: 在scrip框里填入你的入口脚本 之后就可以点击绿色的播放按 ...

  9. Bootstrap3基础 form-horizontal 表单元素横向布局 简单示例

      内容 参数   OS   Windows 10 x64   browser   Firefox 65.0.2   framework     Bootstrap 3.3.7   editor    ...

  10. CSS的再深入2(更新中···)

    在上一章中,我们又引出了一个知识点: margin的问题 margin:0 auto:(上下为0,左右自适应)会解决元素的居中问题(auto 自适应)前提是给这个元素设置width 同时,我们又要学习 ...