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的更多相关文章

  1. CF 990C. Bracket Sequences Concatenation Problem【栈/括号匹配】

    [链接]:CF [题意]: 给出n个字符串,保证只包含'('和')',求从中取2个字符串链接后形成正确的括号序列的方案数(每个串都可以重复使用)(像'()()'和'(())'这样的都是合法的,像')( ...

  2. CF 256D. Good Sequences(DP)

    题目链接 主要是标记前面素数的最大的DP值,要认真一些.没想到居然写了一个很难发现的错误. #include <cstdio> #include <cstring> #incl ...

  3. CF 900D Unusual Sequences

    题目链接 \(Description\) 给定\(x,y\),求有多少个数列满足\(gcd(a_i)=x且\sum a_i=y\).答案对\(10^9+7\)取模. \(1≤x,y≤10^9\) \( ...

  4. (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 ...

  5. CF思维联系– Codeforces-990C Bracket Sequences Concatenation Problem(括号匹配+模拟)

    ACM思维题训练集合 A bracket sequence is a string containing only characters "(" and ")" ...

  6. CF 1329B Dreamoon Likes Sequences

    传送门 题目: Dreamoon likes sequences very much. So he created a problem about the sequence that you can' ...

  7. CF 1272F Two Bracket Sequences (括号dp)

    题目地址 洛谷CF1272F Solution 首先题目中有两个括号串 \(s\) 和 \(t\) ,考虑先设计两维表示 \(s\) 匹配到的位置和 \(t\) 匹配到的位置. 接着根据 括号dp的一 ...

  8. CF集萃3

    CF1118F2 - Tree Cutting 题意:给你一棵树,每个点被染成了k种颜色之一或者没有颜色.你要切断恰k - 1条边使得不存在两个异色点在同一连通块内.求方案数. 解:对每颜色构建最小斯 ...

  9. 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 ...

随机推荐

  1. 一个小程序,时间util

    比较时间,如果此时间是今天的显示时间点,今天以前显日期 public String getTime(Date time){               SimpleDateFormat dateFor ...

  2. UIActionSheet底部弹出框

    <底部弹出框来提示用户信息>    1.遵循代理方法<UIActionSheetDelete>    2.调用放法 [UIActionSheet *sheet=[UIActio ...

  3. Struts2 Spring hibernate 整合示例 .

    示例工具:MyEclipse 8.5.Tomcat 6.0.MySql 步骤: 1.创建一个WEB工程,命名为BookShop(名字自己取,此处为示例工程名): 2.导入struts2的核心jar包, ...

  4. (转)Css样式兼容IE6,IE7,FIREFOX的写法

    根据FF和IE对一些符号识别的差异,我们可以单独对FF以及IE定义样式,例子: 区别IE6与FF:          background:orange;*background:blue;   区别I ...

  5. Excel:您尝试打开的文件的格式与文件扩展名指定的格式不一致

    报错信息: 打开文件时提示"您尝试打开的文件xxx.xls的格式与文件扩展名指定的格式不一致.打开文件前请验证文件没有损坏且来源可信.是否立即打开该文件?",卸载Office 20 ...

  6. webconfig的设置节点几个说明

    有助于深入理解webconfig <?xml version="1.0" encoding="utf-8" ?> <configuration ...

  7. ASP.NET 开发学习视频教程大全(共800集)

      ASP.NET是微软.NET平台的支柱之一,被广泛应用在WEB等互联网开发领域,因此它的强大性和适应性,可以使它运行在Web应用软件开发者的几乎全部的平台上.这里整理了最全的ASP.NET开发学习 ...

  8. Linux2.6的所有内核版本

    Index of /pub/linux/kernel/v2.6 Name Last modified Size Parent Directory - incr/ 03-Aug-2011 20:47 - ...

  9. 动态插入图片到 svg 中

    动态插入图片到 svg 中使用 createElementNS 来创建svg标签,通过setAttributeNS 来设置属性, 要注意两点,创建的时候要有'http://www.w3.org/200 ...

  10. PHP简单计算器

    工作之余,写着玩的. <?php $num1 = $_POST['num1']; $num2 = $_POST['num2']; $yusuan = $_POST['yusuan']; $jie ...