题目传送门

 /*
数学:这题一直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. 易碎的鸟蛋 概率DP

    1007: 易碎的鸟蛋 时间限制: 1 Sec  内存限制: 128 MB提交: 396  解决: 80[提交][状态][讨论版] 题目描述 你们知道吗?西电的跳楼塔上面有一个鸟巢.某SXBK的教授对 ...

  2. 洛谷 P1018 乘积最大

    P1018 乘积最大 题目描述 今年是国际数学联盟确定的“ 20002000 ――世界数学年”,又恰逢我国著名数学家华罗庚先生诞辰 9090 周年.在华罗庚先生的家乡江苏金坛,组织了一场别开生面的数学 ...

  3. COLLECTL LINUX 监控

    http://blog.csdn.net/leichelle/article/details/23590289

  4. maven项目互相dependcy依赖问题

    1.自己编写的maven项目,在编译后,也会在.m2文件夹下生成jar包,可以供第三方引用使用. 2.比如几个项目互相依赖对方的jar包,就要首先选择编译哪个jar包,编译完成后生成jar,再编译依赖 ...

  5. 自己构建的Lumbda表达式

    自己构建的Lumbda表达式 定义接口: package com.stono.lambda; public interface Add { public void add(int x, int y); ...

  6. 【Android归纳】回调机制在Android中的应用与实战

    回调这样的思想在程序中是比較普遍的.有时候可能我们并没有注意到.近期整理了一些对于回调的理解,分享给大家 先上概念...... 什么是回调函数? 回调函数就是一个通过函数指针调用的函数. 假设你把函数 ...

  7. Android 圆形/圆角图片的方法

    Android 圆形/圆角图片的方法 眼下网上有非常多圆角图片的实例,Github上也有一些成熟的项目.之前做项目,为了稳定高效都是选用Github上的项目直接用.但这样的结束也是Android开发必 ...

  8. WebLog Expert

    Weblog expert是一个快速和强大的访问日志分析器.这会让你了解你的网站的访客:活动统计,访问的文件的路径,通过该网站,信息指页面,搜索引擎,浏览器,操作系统,和更多.该计划所产生的易于阅读的 ...

  9. HDU 5324 Boring Class【cdq分治】

    这就是一个三维排序的问题,一维递减,两维递增,这样的问题用裸的CDQ分治恰好能够解决. 如同HDU 4742(三维排序,一个三维都是递增的) 由于最小字典序比較麻烦,所以要从后面往前面做分治.每一个点 ...

  10. spark hadoop 对比 Resilient Distributed Datasets

    hadoop 迭代消耗大 每次迭代启动一个完整的MapReduce作业 spark 首要目标就是避免运算时 过多的网络和磁盘IO开销 Resilient Distributed Datasets ht ...