题目传送门

 /*
数学:这题一直WA在13组上,看了数据才知道是计算cost时超long long了
另外不足一个区间的直接计算个数就可以了
*/
#include <cstdio>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std; typedef unsigned long long ull;
int get_len(ull x)
{
int ret = ;
while (x) {
x /= ; ret++;
}
return ret;
} int main(void) //Codeforces Round #219 (Div. 2) B. Making Sequences is Fun
{
//freopen ("B.in", "r", stdin); ull w, m, k;
while (cin >> w >> m >> k) {
int len = get_len (m); ull mx = ;
for (int i=; i<=len; ++i) {
mx = mx * + ;
} ull ans = ; ull cost = (mx - m + ) * k * len;
while (cost <= w) {
w -= cost; ans += (mx - m + );
len++; m = mx + ; mx = mx * + ;
cost = (mx - m + ) * k * len;
} ans += w / (len * k);
cout << ans << endl;
} return ;
}

 #include <cstdio>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std; typedef long long ll;
int get_len(ll x)
{
int ret = ;
while (x) {
x /= ; ret++;
}
return ret;
} int main(void) //Codeforces Round #219 (Div. 2) B. Making Sequences is Fun
{
//freopen ("B.in", "r", stdin); ll w, m, k;
while (scanf ("%I64d%I64d%I64d", &w, &m, &k) == ) {
int len = get_len (m); ll mx = ;
for (int i=; i<=len; ++i) {
mx = mx * + ;
} ll ans = , now = , tot = ;
while (true) {
now = mx - m + ; tot = w / (k * len);
if (now < tot) {
ans += now; w -= now * k * len;
m = mx + ; mx = mx * + ; len++;
}
else {
ans += tot; break;
}
} printf ("%I64d\n", ans);
} return ;
}

按个数比较

数学 Codeforces Round #219 (Div. 2) B. Making Sequences is Fun的更多相关文章

  1. Codeforces Round #219 (Div. 2) B. Making Sequences is Fun

    B. Making Sequences is Fun time limit per test 2 seconds memory limit per test 256 megabytes input s ...

  2. 贪心/数学 Codeforces Round #212 (Div. 2) A. Two Semiknights Meet

    题目传送门 /* 贪心/数学:还以为是BFS,其实x1 + 4 * k = x2, y1 + 4 * l = y2 */ #include <cstdio> #include <al ...

  3. 数学 Codeforces Round #308 (Div. 2) B. Vanya and Books

    题目传送门 /* 水题:求总数字个数,开long long竟然莫名其妙WA了几次,也没改啥又对了:) */ #include <cstdio> #include <iostream& ...

  4. Codeforces Round #219 (Div. 1)(完全)

    戳我看题目 A:给你n个数,要求尽可能多的找出匹配,如果两个数匹配,则ai*2 <= aj 排序,从中间切断,分成相等的两半后,对于较大的那一半,从大到小遍历,对于每个数在左边那组找到最大的满足 ...

  5. Codeforces Round #219 (Div. 2) E. Watching Fireworks is Fun

    http://codeforces.com/contest/373/problem/E E. Watching Fireworks is Fun time limit per test 4 secon ...

  6. 数学 Codeforces Round #282 (Div. 2) B. Modular Equations

    题目传送门 题意:a % x == b,求符合条件的x有几个 数学:等式转换为:a == nx + b,那么设k = nx = a - b,易得k的约数(>b)的都符合条件,比如a=25 b=1 ...

  7. Codeforces Round #450 (Div. 2) D.Unusual Sequences (数学)

    题目链接: http://codeforces.com/contest/900/problem/D 题意: 给你 \(x\) 和 \(y\),让你求同时满足这两个条件的序列的个数: \(a_1, a_ ...

  8. 数学 Codeforces Round #291 (Div. 2) B. Han Solo and Lazer Gun

    题目传送门 /* 水题,就是用三点共线的式子来判断射击次数 */ #include <cstdio> #include <cmath> #include <string& ...

  9. Codeforces Round #219 (Div. 1) C. Watching Fireworks is Fun

    C. Watching Fireworks is Fun time limit per test 4 seconds memory limit per test 256 megabytes input ...

随机推荐

  1. 走进矩阵树定理--「CodePlus 2017 12 月赛」白金元首与独舞

    n,m<=200,n*m的方阵,有ULRD表示在这个格子时下一步要走到哪里,有一些待决策的格子用.表示,可以填ULRD任意一个,问有多少种填法使得从每个格子出发都能走出这个方阵,答案取模.保证未 ...

  2. MySQL查询去重语句

    1.distinct select count(distinct CName) from Course select count(CName) from (select distinct CName ...

  3. yum install tree 出错primary.sqlite.bz2: [Errno -1] Metadata file does not match checks 解决办法

    Loaded plugins: fastestmirrorLoading mirror speeds from cached hostfilehttp://ftp.sjtu.edu.cn/centos ...

  4. Windows下安Mac

    Windows PC下安装苹果系统 第一步: 準備2個新邏輯分區,一個6G(os),一個隨意(Mac),且不要格式化. 第二步: 启动硬盘助手,选择下载好的苹果镜像文件  .再选择6G(os)分區,寫 ...

  5. C#中Stack&lt;T&gt;类的使用及部分成员函数的源代码分析

    Stack<T>类 Stack<T> 作为数组来实现. Stack<T> 的容量是 Stack<T> 能够包括的元素数. 当向 Stack<T&g ...

  6. 9种样式CSS3 渐变button集

    <!DOCTYPE html> <head> <meta http-equiv="Content-Type" content="text/h ...

  7. nginxserver报403 forbidden错误的解决的方法

     改动nginx.config文件内容: location / {             #root   html;             root   D:\java;            ...

  8. [计算机]如何在win7下查看并更改文件的默认后缀名

    如何在win7下查看默认文件的后缀名并更改呢? 例如有一个文件本来是exe,想变更为txt.但是无法看到后缀名,就无法更改. 双击桌面上的计算机图标,或者任意盘符界面,单击如下图左侧“组织”右侧的下拉 ...

  9. cp和scp

    1 两个命令的格式一样 cp src dst scp src dst 将src文件拷贝到dst目的地.cp是本机拷贝,即从本机的一个地方拷贝到另外一个地方. 而scp是拷贝到远程及其还是从远程机器拷贝 ...

  10. go3--常量和类型转换

    /* Go中不存在隐式转换,所有类型转换必须显式声明 转换只能发生在两种相互兼容的类型之间 类型转换的格式: <ValueA> [:]= <TypeOfValueA>(< ...