思路:

二分。

实现:

 #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. easyui north 穿透

    穿透layout的north 原理 穿透下面的层只要使该层的position置于fix即可 如果该层还有下一级,则下一层级的position置于absolute即可 示例代码 #menu.active ...

  2. Java使用Memcached和Redis简单示例

    package xmq.study.memcached; import java.io.IOException; import java.net.InetSocketAddress; import n ...

  3. 学习swift从青铜到王者之字符串和运算符02

    1 字符和字符串初步  var c :Character = "a" 2 构造字符串  let str1 = "hello" let str2 = " ...

  4. 网易互娱2017实习生招聘游戏研发工程师在线笔试第二场 C

    偶尔碰到这题,简单数位DP题,然而我已生疏了…… 这次算是重新想到的,看来对DP的理解有增进了…… dp[i][j][k],表示前i为,mod为j,是否出现2.3.5的剩下的数位可组成的数字.答案就是 ...

  5. Cocos2dx 小技巧(九)现成的粒子特效

    和高中的她 差点儿相同有两三年没见面了吧.下午她正好来泉州.我俩出来一起吃了个饭. 怎么说呢,自从高中毕业后我俩的联系就少了非常多.大学期间也就见过两三面吧. 现在毕业也快一年了,她已是人妇,而我自己 ...

  6. visio中怎样画线条或箭头

    1.在"画图"工具栏上,单击"铅笔"工具  或"线条"工具  . (凝视   假设看不到"画图"工具栏,请单击" ...

  7. php &amp; 和 &amp;amp; (主要是url 问题)

    ini_set('arg_separator.output','&'); 也能够在php.ini 改动

  8. 2014阿里巴巴WEB前端实习生在线笔试题

    2014年3月31日晚,我怀着稍微忐忑的心情(第一次在线笔试^_^!!)进行了笔试.阿里巴巴的笔试题共同拥有10道,差点儿包括了Web前端开发的各个方面,有程序题.有叙述题.时间很紧张,仅仅完毕了大概 ...

  9. Appro DM8127 IPNC 挂载NFS遇到的问题及解决

    对于Appro DM8127 IPNC,默认的启动方式是NAND is used for booting kernel and NAND is used as root filesystem 为了调试 ...

  10. java json字符串转成 Map或List

    import java.util.List; import java.util.Map; import java.util.Map.Entry; import net.sf.json.JSONArra ...