思路:

二分。

实现:

  1. #include <iostream>
  2. #include <cstdio>
  3. using namespace std;
  4.  
  5. typedef long long ll;
  6.  
  7. const ll MAXN = 1e18;
  8.  
  9. ll n, s;
  10.  
  11. bool check(ll x)
  12. {
  13. ll sum = ;
  14. ll tmp = x;
  15. while (x)
  16. {
  17. sum += x % ;
  18. x /= ;
  19. }
  20. return tmp - sum >= s;
  21. }
  22.  
  23. int main()
  24. {
  25. cin >> n >> s;
  26. ll l = , r = MAXN + , res = MAXN + ;
  27. while (l <= r)
  28. {
  29. ll m = (l + r) >> ;
  30. if (check(m)) r = m - , res = m;
  31. else l = m + ;
  32. }
  33. cout << (n >= res ? n - res + : ) << endl;
  34. return ;
  35. }

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. spring-boot上传文件MultiPartFile获取不到文件问题解决

    1.现象是在spring-boot里加入commons-fileupload jar并且配置了mutilPart的bean,在upload的POST请求后,发现 multipartRequest.ge ...

  2. base64加解密字符串

    import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOExceptio ...

  3. 我的arcgis培训照片8

    来自:http://www.cioiot.com/successview-554-1.html

  4. redhat and centos 系统经常使用命令

    查看cpu信息:     more /proc/cpuinfo |grep "model name"     通常是至强系统 查看内存信息:     grep MemTotal / ...

  5. win7笔记本如何设置共享网络供手机WIFI上网?

    第一步 按WIN+R调出“运行”栏,在“运行”菜单栏输入“cmd”,出现命令提示符,输入命令“netsh wlan set hostednetwork mode=allow ssid=xiaoming ...

  6. VMware实用技巧

    1.VM快照管理 这个功能实在太常用,不用我多废话.这里只是提醒一下还没有用过快照的同学,赶紧的给自己的VM保存点快照吧,这样VM里的系统出了问题或是有其它需要很容易让你还原到原来的某个点,这功能可比 ...

  7. Android Jni Android.mk经常使用语句

    仅仅要涉及JNI开发都涉及到Android.mk编写,它也是一种makefile语言. 以上一篇博客中提供的project为例! <1> : 信息打印 : 既然是一种简易语言那么首先应该知 ...

  8. 滚动载入server端内容——样例

    网页代码例如以下 <!doctype html> <html> <head> <meta charset="utf-8"> < ...

  9. docker (1) ---简介,使用

    一.docker简介: 容器( container-based )虚拟化方案,充分利用了操作系统本身已有的机 制和特性,以实现轻量级的虚拟化(每个虚拟机安装的不是完整的虚拟机), 甚至有人把他称为新一 ...

  10. 关于使用Xshell远程连接启动tomcat导致图片不显示,报错Could not initialize class sun.awt.X11GraphicsEnvironment解决方案

    如果您是使用xshell远程启动tomcat,导致二维码.验证码,头像等各种图片不显示,并且打开图片链接报错Could not initialize class sun.awt.X11Graphics ...