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 ...
随机推荐
- Demo_CS(移动,切换枪支,发射子弹)
using UnityEngine; using System.Collections; public class Gun : MonoBehaviour { private Animator ani ...
- WCF:如何将net.tcp协议寄宿到IIS
1 部署IIS 1.1 安装WAS IIS原本是不支持非HTTP协议的服务,为了让IIS支持net.tcp,必须先安装WAS(Windows Process Activation Service),即 ...
- VMware vSphere 服务器虚拟化之二十五 桌面虚拟化之终端服务池
VMware vSphere 服务器虚拟化之二十五 桌面虚拟化之终端服务池 终端服务池是指由一台或多台微软终端服务器提供服务的桌面源组成的池.终端服务器桌面源可交付多个桌面.它具有以下特征: 1.终端 ...
- google(转帖)
本帖最后由 qiushui_007 于 2014-6-10 16:14 编辑 IP Addresses of Google Global Cachewww.kookle.co.nr Bulgaria ...
- Android系统移植与驱动开发----第一章
第一章 Android系统移植与驱动开发 Android源代码定制完全属于自己的嵌入式系统,但是支持的设备不多,所以要移植,而在移植的过程中使用的不得不提的是驱动开发. Android系统构架主要包括 ...
- python 之路,Day11 (下)- sqlalchemy ORM
python 之路,Day11 - sqlalchemy ORM 本节内容 ORM介绍 sqlalchemy安装 sqlalchemy基本使用 多外键关联 多对多关系 表结构设计作业 1. ORM ...
- codevs3013单词背诵
/* 手打的哈希+线性的维护 第一问:hash一下 并且用个h记录某个单词要背的 第二问:线性的跑一边 开始队列里装下前一些单词使这一坨符合要求 并且记录出现次数num 然后开始从前面删 删除的条件: ...
- __name__属性
#coding=utf-8#首先我们分别看一下这个模块在不同场景中的__name__的值print __name__ #其次我们看一下__name__属性的常用情况if __name__==" ...
- datagrid加下拉列表dropdownlist
datagrid中代码: <asp:datagrid id="dgList" runat="server" ItemStyle-HorizontalAli ...
- 在Global.asax文件里实现通用防SQL注入漏洞程序(适应于post/get请求)
可使用Global.asax中的Application_BeginRequest(object sender, EventArgs e)事件来实现表单或者URL提交数据的获取,获取后传给SQLInje ...