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. SQL表分区之二

    前面说的给表做表分区,现在有个问题,比如上面我们说的是按照20w为一个分割线,那些现在我们想把这个调整下怎么办?难道要把之前的分区函数和分区方案删了,重新新建分区函数和分区方案嘛? 当然,此方式肯定是 ...

  2. Django框架----命名空间模式

    命名空间模式 即使不同的APP使用相同的URL名称,URL的命名空间模式也可以让你唯一反转命名的URL. 举个例子: project中的urls.py from django.conf.urls im ...

  3. Linux(64) 下 Tomcat + java 环境搭建

    查看 linux 系统位数 getconf LONG_BIT java  JDK下载地址: http://download.oracle.com/otn-pub/java/jdk/8u181-b13/ ...

  4. GC Root 对象有哪些

    (1)虚拟机(JVM)栈中引用对象 (2)方法区中的类静态属性引用对象   (3)方法区中常量引用的对象(final 的常量值) (4)本地方法栈JNI的引用对象

  5. MySQL SELECT练习题*28

    -- (1)用子查询查询员工“张小娟”所做的订单信息. SELECT * FROM order_master WHERE saler_no = ( SELECT employee_no FROM em ...

  6. shell 中的小技巧

    去掉最后一个字符 sed 's/.$//' awk '{sub(/.$/,"")}1' awk '{printf $0"\b \n"}' [root@ ~]# ...

  7. Golang实现二分查找法

    二分查找法就是实现在一组有序的数字数组集合中最快找到指定元素的下标 思路 ①先找到中间的下标middle = (leftIndex + RightIndex) /2 ,然后让中间的下标值和FindVa ...

  8. P2048 [NOI2010]超级钢琴(RMQ+堆+贪心)

    P2048 [NOI2010]超级钢琴 区间和--->前缀和做差 多次查询区间和最大--->前缀和RMQ 每次取出最大的区间和--->堆 于是我们设个3元组$(o,l,r)$,表示左 ...

  9. Linux 编程简单示例代码

    Linux进程管理 编辑a.c 文件 #include <stdio.h> #include <unistd.h> int main() { printf( "Mes ...

  10. 螺旋折线(可能是最简单的找规律)【蓝桥杯2018 C/C++ B组】

    标题:螺旋折线 如图p1.png所示的螺旋折线经过平面上所有整点恰好一次.   对于整点(X, Y),我们定义它到原点的距离dis(X, Y)是从原点到(X, Y)的螺旋折线段的长度. 例如dis(0 ...