题目传送门

 /*
数学:这题一直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. Linux下汇编语言学习笔记15 ---

    这是17年暑假学习Linux汇编语言的笔记记录,参考书目为清华大学出版社 Jeff Duntemann著 梁晓辉译<汇编语言基于Linux环境>的书,喜欢看原版书的同学可以看<Ass ...

  2. 使用GSON解析JSON文件

    package com.pingyijinren.test; /** * Created by Administrator on 2016/5/19 0019. */ public class App ...

  3. POJ 1804 逆序对数量 / 归并排序

    Brainman Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 12175   Accepted: 6147 Descrip ...

  4. CSS3(各UI元素状态伪类选择器受浏览器的支持情况)

    选择器 Firefox Safari Opera IE Chrome E:hover Y Y Y Y Y E:active Y Y Y N Y E:focus Y Y Y Y Y E:enabled ...

  5. uva 1411 Ants (权值和最小的完美匹配---KM算法)

    uva 1411 Ants Description Young naturalist Bill studies ants in school. His ants feed on plant-louse ...

  6. Android入门级编译错误汇总

    1  描写叙述:  项目常常须要引用别人的libraryproject,在选项中add进来后,点击应用或者确定.关闭页面. 回到代码中却发现无法链接,又一次打开properties查看,发现导入的pr ...

  7. hdu, KMP algorithm, linear string search algorithm, a nice reference provided

    reference: Rabin-Karp and Knuth-Morris-Pratt Algorithms By TheLlama– TopCoder Member https://www.top ...

  8. dm385和8127的区别

    DM385/DM8127在ITS智能交通中的应用分析德州仪器(TI)自推出DM385和DM8127视频处理器在业界反响很大特别是深圳安博会上展出的1080P60帧高清效果之后很多龙头企业也跃 ...

  9. Linq To Sql 增改删

    using System; using System.Data.Linq.Mapping; namespace ConsoleApplication3 { [Table(Name = "te ...

  10. JavaScript基础 -- 定时器

     js 定时器有以下两个方法: setInterval() :按照指定的周期(以毫秒计)来调用函数或计算表达式.方法会不停地调用函数,直到 clearInterval() 被调用或窗口被关闭. set ...