思路:

二分。

实现:

 #include <iostream>
#include <cstdio>
using namespace std; typedef long long ll; const ll MAXN = 1e18; ll n, s; bool check(ll x)
{
ll sum = ;
ll tmp = x;
while (x)
{
sum += x % ;
x /= ;
}
return tmp - sum >= s;
} int main()
{
cin >> n >> s;
ll l = , r = MAXN + , res = MAXN + ;
while (l <= r)
{
ll m = (l + r) >> ;
if (check(m)) r = m - , res = m;
else l = m + ;
}
cout << (n >= res ? n - res + : ) << endl;
return ;
}

CF817C Really Big Numbers的更多相关文章

  1. Java 位运算2-LeetCode 201 Bitwise AND of Numbers Range

    在Java位运算总结-leetcode题目博文中总结了Java提供的按位运算操作符,今天又碰到LeetCode中一道按位操作的题目 Given a range [m, n] where 0 <= ...

  2. POJ 2739. Sum of Consecutive Prime Numbers

    Sum of Consecutive Prime Numbers Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 20050 ...

  3. [LeetCode] Add Two Numbers II 两个数字相加之二

    You are given two linked lists representing two non-negative numbers. The most significant digit com ...

  4. [LeetCode] Maximum XOR of Two Numbers in an Array 数组中异或值最大的两个数字

    Given a non-empty array of numbers, a0, a1, a2, … , an-1, where 0 ≤ ai < 231. Find the maximum re ...

  5. [LeetCode] Count Numbers with Unique Digits 计算各位不相同的数字个数

    Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10n. Examp ...

  6. [LeetCode] Bitwise AND of Numbers Range 数字范围位相与

    Given a range [m, n] where 0 <= m <= n <= 2147483647, return the bitwise AND of all numbers ...

  7. [LeetCode] Valid Phone Numbers 验证电话号码

    Given a text file file.txt that contains list of phone numbers (one per line), write a one liner bas ...

  8. [LeetCode] Consecutive Numbers 连续的数字

    Write a SQL query to find all numbers that appear at least three times consecutively. +----+-----+ | ...

  9. [LeetCode] Compare Version Numbers 版本比较

    Compare two version numbers version1 and version1.If version1 > version2 return 1, if version1 &l ...

随机推荐

  1. python爬虫实现原理

    前言 简单来说互联网是由一个个站点和网络设备组成的大网,我们通过浏览器访问站点,站点把HTML.JS.CSS代码返回给浏览器,这些代码经过浏览器解析.渲染,将丰富多彩的网页呈现我们眼前: 一.爬虫是什 ...

  2. Oracle数据库导入导出简单备份

    oracle数据库简单备份 方法一: 1.导出 exp c##xmq/pwda@orcl owner=c##xmq file=C:/expdb.dmp buffer=8000 2.导入 2.1.删除原 ...

  3. JS获取地址栏并拼接參数

    比方地址栏是这种:http://www.aa.com/detail.aspx?code=1&start=2014-12-01&end=2014-12-23&name=abc 要 ...

  4. react 项目实战(四)组件化表单/表单控件 高阶组件

    高阶组件:formProvider 高阶组件就是返回组件的组件(函数) 为什么要通过一个组件去返回另一个组件? 使用高阶组件可以在不修改原组件代码的情况下,修改原组件的行为或增强功能. 我们现在已经有 ...

  5. C++ auto 与 register、static keyword 浅析

    [register/auto的比較分析] #include <iostream> using namespace std; int main(){ int i,sum=0; for(i=0 ...

  6. 【iOS开发-74】解决方式:Xcode6下利用preference保存数据,终于的plist文件在哪里?

    (1)现象:普通情况下.储存数据以一个沙盒为单位,preference数据存在在沙盒路径下Library/Preferences里面,可是Xcode6里找来找去根本什么都没有. watermark/2 ...

  7. ASP.NET Boilerplate 学习 AspNet Core2 浏览器缓存使用 c#基础,单线程,跨线程访问和线程带参数 wpf 禁用启用webbroswer右键菜单 EF Core 2.0使用MsSql/MySql实现DB First和Code First ASP.NET Core部署到Windows IIS QRCode.js:使用 JavaScript 生成

    ASP.NET Boilerplate 学习   1.在http://www.aspnetboilerplate.com/Templates 网站下载ABP模版 2.解压后打开解决方案,解决方案目录: ...

  8. Struts2默认拦截器栈及内建拦截器使用具体解释

    Struts2内建拦截器介绍:   alias (别名拦截器):同意參数在跨越多个请求时使用不同别名,该拦截器可将多个Action採用不同名字链接起来,然后用于处理同一信息.  autowiring  ...

  9. 在shell脚本中执行shell脚本

    任务下发 主节点脚本 任务管控脚本 [root@admin1 ~]# cat mytest.sh echo lovecode [root@admin1 ~]# cat myfor.sh #!/bin/ ...

  10. [Unity-21] Prefab具体解释

    1.什么是Prefab? Prefab又被称为预设,以下部分来自官网:预置是一种资源类型--存储在项目视图中的一种可反复使用的游戏对象.预置能够多次放入到多个场景中. 当你加入一个预置到场景中,就创建 ...