Educational Codeforces Round 23C
超级坑的水题!!!想了两天没一点思路,看了题解第一段话就做出来了
刚开始一直在想找到通项就是例如an*10^n+...+a0*10^0-an-...-a0>=s,然后从这个里面找到规律,结果走进死胡同了
Let's prove that if x is really big, then x + 1 is really big too.
证明很容易,我就不证了,直接上代码,二分答案就行了
还有一点要注意,因为是10E18范围,所以平时循环50次是不够用的,加到了70次就ac了,也可以用l<r-1这个来判断
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<cstdio>
#include<cassert>
#include<iomanip>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define pi acos(-1)
#define ll long long
#define mod 1000000007
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#pragma comment(linker, "/STACK:1024000000,1024000000") using namespace std; const double g=10.0,eps=1e-;
const int N=+,maxn=,inf=; ll n,s;
bool ok(ll x)
{
ll t=x,p=x;
while(p){
t-=(p%);
p/=;
}
return t>=s;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie();
cin>>n>>s;
ll l=,r=n+;
for(int i=;i<;i++)
{
ll m=(l+r)/;
if(ok(m))r=m;
else l=m;
}
cout<<n-l<<endl;
return ;
}
Educational Codeforces Round 23C的更多相关文章
- [Educational Codeforces Round 16]E. Generate a String
[Educational Codeforces Round 16]E. Generate a String 试题描述 zscoder wants to generate an input file f ...
- [Educational Codeforces Round 16]D. Two Arithmetic Progressions
[Educational Codeforces Round 16]D. Two Arithmetic Progressions 试题描述 You are given two arithmetic pr ...
- [Educational Codeforces Round 16]C. Magic Odd Square
[Educational Codeforces Round 16]C. Magic Odd Square 试题描述 Find an n × n matrix with different number ...
- [Educational Codeforces Round 16]B. Optimal Point on a Line
[Educational Codeforces Round 16]B. Optimal Point on a Line 试题描述 You are given n points on a line wi ...
- [Educational Codeforces Round 16]A. King Moves
[Educational Codeforces Round 16]A. King Moves 试题描述 The only king stands on the standard chess board ...
- Educational Codeforces Round 6 C. Pearls in a Row
Educational Codeforces Round 6 C. Pearls in a Row 题意:一个3e5范围的序列:要你分成最多数量的子序列,其中子序列必须是只有两个数相同, 其余的数只能 ...
- Educational Codeforces Round 9
Educational Codeforces Round 9 Longest Subsequence 题目描述:给出一个序列,从中抽出若干个数,使它们的公倍数小于等于\(m\),问最多能抽出多少个数, ...
- Educational Codeforces Round 37
Educational Codeforces Round 37 这场有点炸,题目比较水,但只做了3题QAQ.还是实力不够啊! 写下题解算了--(写的比较粗糙,细节或者bug可以私聊2333) A. W ...
- Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship
Problem Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship Time Limit: 2000 mSec P ...
随机推荐
- php中函数preg_match或preg_match_all 第三个参数$match的解释
理解自:http://www.cnblogs.com/vicenteforever/articles/1623137.html php手册中是这样解释的 matches 如果提供了参数matches, ...
- JIRA licence crack and etc
https://my.oschina.net/u/199525/blog/313788 http://blog.csdn.net/joinandjoin/article/details/9052785 ...
- Android-aidl, binder,surfaceview
http://blog.csdn.net/stonecao/article/details/6425019 http://www.cnblogs.com/linucos/archive/2012/05 ...
- Python开发【Django】:缓存、信号
缓存 由于Django是动态网站,所有每次请求均会去数据进行相应的操作,当程序访问量大时,耗时必然会更加明显,最简单解决方式是使用:缓存,缓存将一个某个views的返回值保存至内存或者memcache ...
- Python将科学计数法数值转换为指定精度浮点数
Python将科学计数法数值转换为指定精度浮点数 In [20]:money = 1190000.0 In [21]: traded_maket_value = 13824000000 In [22] ...
- 【Linux学习 】Linux使用Script命令来记录并回放终端会话
一背景 二script命令简介 1 什么script命令 2 script命令操作 21 file选项 22 options选项 23 退出script 三Script命令结合实际使用场景 1 先在终 ...
- (2.11)Mysql之SQL基础——存储过程与变量
(2.11)Mysql之SQL基础——存储过程 关键字:mysql存储过程 查看存储过程: []SELECT * FROM information_schema.ROUTINES WHERE ROUT ...
- java-基础-【四】实际编程中的对象
一.概述 实际编程开发中,仅仅一个数据库对象映射是满足不了各种复杂需求. O/R Mapping 是 Object Relational Mapping(对象关系映射)的缩写.通俗点讲,就是将对象与关 ...
- VMware跨电脑移动Linux虚拟机
环境:VMware-Workstation-12-Pro,Windows-10,CentOS-6.9-x86_64,Xshell5 概况 vmware自带的快照,克隆功能,都可以实现备份虚拟机的功能, ...
- NULL头文件
#include<stddef.h> NULL不是C语言基本类型,其定义在stddef.h文件中,作为最基本的语言依赖宏存在.但是随着C/C++的发展,很多文件只要涉及了系统或者标准操作都 ...