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. DCL双检查锁机制实现的线程安全的单例模式

    public class MyObject { private volatile static MyObject myObject; private MyObject(){} public stati ...

  2. SpringMVC在上传文件的时候提示The current request is not a multipart request错误

    @RequestMapping("/insertOrder") @ResponseBody public  Object insertOrder(String userId,Htt ...

  3. CodeForces 55D Beautiful numbers(数位dp)

    数位dp,三个状态,dp[i][j][k],i状态表示位数,j状态表示各个位上数的最小公倍数,k状态表示余数 其中j共有48种状态,最大的是2520,所以状态k最多有2520个状态. #include ...

  4. [Flux] Stores

    Store, in Flux which manager the state of the application. You can use EventEmiiter to listen to the ...

  5. Block小结

    Blocks是C语言的扩充功能.用一句话来表示Blocks的扩充功能:带有自动变量(局部变量)的匿名函数. block其实是一个代码块,但是它的神奇之处在于在内联(inline)执行的时候(这和C++ ...

  6. SPOJ 181 - Scuba diver 二维背包

    潜水员要潜水,给出n个气缸(1<=n<=1000),每个气缸中有氧气量为ti,氮气量为ai,气缸重量为wi(1<=ti<=21,1<=ai<=79,1<=wi ...

  7. JSON 遍历转为Model Bean

    @RequestMapping(value = "/batchAddPageIndexBrand") @ResponseBody public HashMap<String, ...

  8. div如何加滚动条

    <div style="position:absolute; height:400px; overflow:auto"></div>div 设置滚动条显示: ...

  9. 开源的Android开发框架-------PowerFramework使用心得(三)内置浏览器BrowserActivity

    使用内置浏览器必须是引用源码的方式(因为jar中不能打包布局文件等资源).内置浏览器是一个继承自BaseActivity的普通Activity,使用WebView实现. 1.简单的打开内置浏览器 In ...

  10. 通知(Notification)的使用

    新建一个 NotificationTest项目,并修改 activity_main.xml 中的代码,如下所示:<LinearLayout xmlns:android="http:// ...