Educational Codeforces Round 23 C. Really Big Numbers 暴力
1 second
256 megabytes
standard input
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.
The first (and the only) line contains two integers n and s (1 ≤ n, s ≤ 1018).
Print one integer — the quantity of really big numbers that are not greater than n.
12 1
3
25 20
0
10 9
1
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 暴力的更多相关文章
- 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 ...
- Educational Codeforces Round 13 A. Johny Likes Numbers 水题
A. Johny Likes Numbers 题目连接: http://www.codeforces.com/contest/678/problem/A Description Johny likes ...
- Educational Codeforces Round 23.C
C. Really Big Numbers time limit per test 1 second memory limit per test 256 megabytes input standar ...
- 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 ...
- 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 ...
- Educational Codeforces Round 23 A-F 补题
A Treasure Hunt 注意负数和0的特殊处理.. 水题.. 然而又被Hack了 吗的智障 #include<bits/stdc++.h> using namespace std; ...
- Educational Codeforces Round 23 D. Imbalanced Array 单调栈
D. Imbalanced Array time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- Educational Codeforces Round 23 补题小结
昨晚听说有教做人场,去补了下玩. 大概我的水平能做个5/6的样子? (不会二进制Trie啊,我真菜) A. 傻逼题.大概可以看成向量加法,判断下就好了. #include<iostream> ...
- Educational Codeforces Round 23
A题 分析:注意两个点之间的倍数差,若为偶数则为YES,否则为NO #include "iostream" #include "cstdio" #include ...
随机推荐
- [转载]Request、Request.Form和Request.QueryString的区别
Request.Request.Form和Request.QueryString的区别 request本身是一个系统的静态对象,本身也可以作为数组调用,比如request("abc" ...
- 怎样从外网访问内网PostgreSQL数据库?
本地安装了一个PostgreSQL数据库,只能在局域网内访问到,怎样从外网也能访问到本地的PostgreSQL数据库呢?本文将介绍具体的实现步骤. 1. 准备工作 1.1 安装并启动PostgreSQ ...
- JavaScript笔记 #07# 用js写算法
算法盒子初代(为了提高学习算法的热情...) 效果图: 所有代码放在单个html中: <!DOCTYPE html> <html> <head> <meta ...
- Android开发发布真机调试
使用真机测试原因: 1. 模拟器启动慢,真机测试速度较快 2. 有些程序在真机测试才有效,模拟器存在bug,结果要以真机为标准 连接方法: 1.设置手机为开发者模式(设置->关于手机->连 ...
- Qone 自动删除说说脚本
请看图 script var delay = 1000; function del() { document.querySelector('.app_canvas_frame').contentDoc ...
- Java开发人员必会的基本Linux命令(转)
原文链接:http://www.cnblogs.com/zhuawang/p/5212809.html http://explainshell.com/ 本文并不会对所有命令进行详细讲解,只给出常见用 ...
- 20145212 罗天晨 WEB登陆发贴及会话管理功能的实现
会话管理简介 Cookie: cookie常用于识别用户. cookie 是服务器留在用户计算机中的小文件,每当相同的计算机通过浏览器请求页面时,它同时会发送 cookie. 通过PHP能够创建并取回 ...
- JS深拷贝/深克隆(面试用)
晒下我的比较浅显的深拷贝,没有考虑原型和循环引用,可以拷贝一些js原生类型,用于面试用. function deepClone(obj){ if(Object.prototype.toString.c ...
- bzoj 4237 稻草人 - CDQ分治 - 单调栈
题目传送门 传送点I 传送点II 题目大意 平面上有$n$个点.问存在多少个矩形使得只有左下角和右上角有点. 考虑枚举左下角这个点.然后看一下是个什么情况: 嗯对,是个单调栈.但不可能暴力去求每个点右 ...
- GDPR
http://column.caijing.com.cn/20180523/4457753.shtml