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 ...
随机推荐
- 静态绑定 self 和 static的区别
后期静态绑定 自 PHP 5.3.0 起,PHP 增加了一个叫做后期静态绑定的功能,用于在继承范围内引用静态调用的类. 准确说,后期静态绑定工作原理是存储了在上一个“非转发调用”(non-forwar ...
- move_uploaded_file() 函数
定义和用法 move_uploaded_file() 函数将上传的文件移动到新位置. 若成功,则返回 true,否则返回 false. 语法 move_uploaded_file(file,newlo ...
- js jquery.pagination.js分页
1.使用插件为 jquery.pagination.js ,如果没有这个js文件的话,我可以给发个. 首先引用 jquery.pagination.js (分页js),跟pagination.css( ...
- 传智播客京东商城移动web开发
1.源码笔记 我的源码+笔记(很重要):链接: https://pan.baidu.com/s/1eScieps 密码: 3vyr 感谢传智播客项目相关视频:1.6天链接: https://pan.b ...
- CodeForces 651 C Watchmen
C. Watchmen time limit per test 3 seconds memory limit per test 256 megabytes input standard input o ...
- Python开发【数据结构】:算法(一)
算法基础 1.什么是算法? 算法(Algorithm):一个计算过程,解决问题的方法 2.复习:递归 递归的两个特点: 调用自身 结束条件 两个重要递归函数的对比: # 由大到小 def func3( ...
- xshell过期了怎么办,是学生就用学生版吧
访问这里:https://www.netsarang.com/download/software.html 点击Free for Home & School 下载家庭版和学生版 来到这个页面了 ...
- Codeforces Round #520 (Div. 2) Solution
A. A Prank Solved. 题意: 给出一串数字,每个数字的范围是$[1, 1000]$,并且这个序列是递增的,求最多擦除掉多少个数字,使得别人一看就知道缺的数字是什么. 思路: 显然,如果 ...
- springcloud20---Config加入eureka
Config server也可以加用户名和密码.Config client通过用户名和密码访问. Config server也可以做成高可用集群. Config与eureka配置使用.把Config ...
- java 加密之消息摘要算法
简介 消息摘要算法的主要特征是加密过程不需要密钥,并且经过加密的数据无法被解密,即单向加密,只有输入相同的明文数据经过相同的消息摘要算法才能得到相同的密文. 消息摘要算法不存在密钥的管理与分发问题,适 ...