题目传送门

 /*
数学:这题一直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. SpringBoot Data JPA 关联表查询的方法

    SpringBoot Data JPA实现 一对多.多对一关联表查询 开发环境 IDEA 2017.1 Java1.8 SpringBoot 2.0 MySQL 5.X 功能需求 通过关联关系查询商店 ...

  2. 【NOIP2017练习】怎样学习哲学(计数,DP)

    题意:OI大师抖儿在夺得银牌之后,顺利保送pku.这一天,抖儿问长者:“虽然我已经保送了,但是我还要参加学考.马上就要考政治了,请问应该怎样学习哲学,通过政治考试?”  长者回答:“你啊,Too Yo ...

  3. POJ 3255_Roadblocks

    题意: 无向图,求单源次短路,每条边可以走多次. 分析: 对于每个点记录最短路和次短路,次短路可以是由最短路+边或者是次短路+边更新而来.在更新每个点的最短路时,相应更新次短路,如果最短路更新了,就令 ...

  4. Linux系统备份还原工具2(TAR/压缩工具)

    相比DD备份还原工具,TAR压缩还原工具更加小巧和灵活,但是不能备份MBR.当然可以通过重新安装GRUB来解决MBR的这一问题.同时,TAR的做法也是官方推荐的. 注意:一个硬盘启动时最新经过MBR( ...

  5. MongoDB小结05 - update【$set & $unset】

    用$set指定一个键的值,如果不存在,就创建它.这对更新模式或者增加用户定义很有帮助. db.user.insert({"name":"codingwhy.com&quo ...

  6. JS函数节流代码实现

    函数被频繁调用场景 Js中的函数大多数情况下都是由用户主动调用触发的,一般不会遇到性能相关的问题.但在一些少数情况下,函数的触发不是由用户直接控制.在这些场景下,函数有可能被非常频繁地调用,而造成大的 ...

  7. linux 的硬链接与软连接

    linux 里有硬链接和软连接两种概念.要明白这些概念首先要明白文件在linux 上其实有3个组成部分. data 真正的数据存储区域 inode 一个用来唯一表示data的数据结构 filename ...

  8. maven 手动构建项目

    maven 手动构建项目 在空目录下面: D:\test>mvn -B archetype:generate -DarchetypeGroupId=org.apache.maven.archet ...

  9. Codeforces Beta Round #2 B. The least round way

    这个2B题还好~~ 题目大意: 给出一个矩阵.从左上走到右下,仅仅能往右或下走.路径中每一个格子有一个数.这些数相乘得出一个数. 求这个数末尾零最少的一条路径. 解题思路: 找出一条路径.乘积得数中素 ...

  10. 2013:Audio Tag Classification - MIREX Wiki

    Contents [hide] 1 Description 1.1 Task specific mailing list 2 Data 2.1 MajorMiner Tag Dataset 2.2 M ...