cf B. Making Sequences is Fun
http://codeforces.com/contest/373/problem/B
用二分枚举长度就可以。
#include <cstdio>
#include <cstring>
#include <algorithm>
#define LL __int64
using namespace std; LL w,m,k; bool ok(LL c)
{
LL ans=;
LL x2=m+c-;
int t1=;
LL b=x2;
while(b)
{
b/=;
t1++;
}
int t2=;
LL b1=m;
while(b1)
{
b1/=;
t2++;
}
if(t1==t2)
{
ans+=c*t1*k;
if(ans<=w&&ans>=) return true;
else return false;
}
LL x1=;
int a1=t1-;
while(a1--)
{
x1*=;
}
ans+=(x2-x1+)*t1*k;
LL x3=;
int a2=t2;
while(a2--)
{
x3*=;
}
ans+=(x3-m)*t2*k;
for(LL i=x3; i<x1; i*=)
{
t2++;
ans+=(i*-i)*t2*k;
}
if(ans<=w&&ans>=) return true;
else return false; } int main()
{
while(scanf("%I64d%I64d%I64d",&w,&m,&k)!=EOF)
{
LL l=,r=w;
LL ans=;
while(l<=r)
{
LL mid=(l+r)/;
if(ok(mid))
{
ans=mid;
l=mid+;
}
else
r=mid-;
}
printf("%I64d\n",ans);
}
return ;
}
cf B. Making Sequences is Fun的更多相关文章
- CF 990C. Bracket Sequences Concatenation Problem【栈/括号匹配】
[链接]:CF [题意]: 给出n个字符串,保证只包含'('和')',求从中取2个字符串链接后形成正确的括号序列的方案数(每个串都可以重复使用)(像'()()'和'(())'这样的都是合法的,像')( ...
- CF 256D. Good Sequences(DP)
题目链接 主要是标记前面素数的最大的DP值,要认真一些.没想到居然写了一个很难发现的错误. #include <cstdio> #include <cstring> #incl ...
- CF 900D Unusual Sequences
题目链接 \(Description\) 给定\(x,y\),求有多少个数列满足\(gcd(a_i)=x且\sum a_i=y\).答案对\(10^9+7\)取模. \(1≤x,y≤10^9\) \( ...
- (CF#257)B. Jzzhu and Sequences
Jzzhu has invented a kind of sequences, they meet the following property: You are given x and y, ple ...
- CF思维联系– Codeforces-990C Bracket Sequences Concatenation Problem(括号匹配+模拟)
ACM思维题训练集合 A bracket sequence is a string containing only characters "(" and ")" ...
- CF 1329B Dreamoon Likes Sequences
传送门 题目: Dreamoon likes sequences very much. So he created a problem about the sequence that you can' ...
- CF 1272F Two Bracket Sequences (括号dp)
题目地址 洛谷CF1272F Solution 首先题目中有两个括号串 \(s\) 和 \(t\) ,考虑先设计两维表示 \(s\) 匹配到的位置和 \(t\) 匹配到的位置. 接着根据 括号dp的一 ...
- CF集萃3
CF1118F2 - Tree Cutting 题意:给你一棵树,每个点被染成了k种颜色之一或者没有颜色.你要切断恰k - 1条边使得不存在两个异色点在同一连通块内.求方案数. 解:对每颜色构建最小斯 ...
- ORA-00494: enqueue [CF] held for too long (more than 900 seconds) by 'inst 1, osid 5166'
凌晨收到同事电话,反馈应用程序访问Oracle数据库时报错,当时现场现象确认: 1. 应用程序访问不了数据库,使用SQL Developer测试发现访问不了数据库.报ORA-12570 TNS:pac ...
随机推荐
- input页面居中,软键盘覆盖input
input框位于底部 对于ios的软键盘遮盖input输入框问题,网上已经有了一些解决办法,无非就是改变布局,再加scroll.js插件实现滚动, input框位于顶部 这种情况不会出现问题, inp ...
- linux防火墙 基础知识
转 http://drops.wooyun.org/tips/1424 iptables介绍 linux的包过滤功能,即linux防火墙,它由netfilter 和 iptables 两个组件组成. ...
- Ubuntu 添加桌面快捷方式
使用Linux Desktop Entry创建 ~$ cd ~/Desktop/ ~$ vim AndroidStudio.desktop 插入以下代码 [Desktop Entry] Encodin ...
- Android源码学习
http://android-wheel.googlecode.com/svn/trunk/android-wheel-read-only 在github上面有一个叫做 android-wheel 的 ...
- arm-linux移植MT7601Uusb无线网卡(小度wifi,360随身WIFI 2代)
前段时间移植过RT3070.RT5370 http://blog.csdn.net/ofaith12345/article/details/24138399 发现各种arm移植都大同小异,所以就不要纠 ...
- CentOS 安装 Tomcat
1.Tomcat官网获(http://tomcat.apache.org/)取tar.gz文件的下载地址 2.下载: # wget http://apache.fayea.com/tomcat/tom ...
- IOS Dictionary和Model相互转换
// // HYBJSONModel.h // Json2ModelDemo // // Created by huangyibiao on 14-9-15. // Copyright (c) 201 ...
- HTML中常见的各种位置距离以及dom中的坐标讨论
最近在学习JavaScript,特意买了一本犀牛角书来看看,尼玛一千多页,看的我头昏脑涨,翻到DOM这章节,突然记起平常在使用DOM时,碰到了好多的这个dom里面的各种宽度,高度,特意在此写一写,写的 ...
- 如何在macos下创建文件或者文件夹的快捷方式
用的时间久了就发现一次次的打开finder的次数多了,每次打开每次都要一层层的去点开一个个文件夹,太复杂了,然而右键也没有windows中发送到快捷方式到桌面的选项 于是Google一下,按住comm ...
- WebService简单使用
1.创建Webservice服务应用程序 方式一:将VS2010采用的默认框架,改为使用框架.NET Framework2.0\3.0\3.5,这时新建"项目"or新建" ...