数学 Codeforces Round #219 (Div. 2) B. Making Sequences is Fun
/*
数学:这题一直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的更多相关文章
- 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 ...
- 贪心/数学 Codeforces Round #212 (Div. 2) A. Two Semiknights Meet
题目传送门 /* 贪心/数学:还以为是BFS,其实x1 + 4 * k = x2, y1 + 4 * l = y2 */ #include <cstdio> #include <al ...
- 数学 Codeforces Round #308 (Div. 2) B. Vanya and Books
题目传送门 /* 水题:求总数字个数,开long long竟然莫名其妙WA了几次,也没改啥又对了:) */ #include <cstdio> #include <iostream& ...
- Codeforces Round #219 (Div. 1)(完全)
戳我看题目 A:给你n个数,要求尽可能多的找出匹配,如果两个数匹配,则ai*2 <= aj 排序,从中间切断,分成相等的两半后,对于较大的那一半,从大到小遍历,对于每个数在左边那组找到最大的满足 ...
- 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 ...
- 数学 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 ...
- Codeforces Round #450 (Div. 2) D.Unusual Sequences (数学)
题目链接: http://codeforces.com/contest/900/problem/D 题意: 给你 \(x\) 和 \(y\),让你求同时满足这两个条件的序列的个数: \(a_1, a_ ...
- 数学 Codeforces Round #291 (Div. 2) B. Han Solo and Lazer Gun
题目传送门 /* 水题,就是用三点共线的式子来判断射击次数 */ #include <cstdio> #include <cmath> #include <string& ...
- 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 ...
随机推荐
- Thinkphp5.0 的使用模型Model添加数据
Thinkphp5.0 的使用模型Model添加数据 使用create()方法添加数据 $res = TestUser::create([ 'name' => 'zhao liu', 'pass ...
- 在fragment中获取activity的组件
在fragment中使用getActivity()即可获取activity的引用
- [bzoj1059][ZJOI2007]矩阵游戏_二分图最大匹配
矩阵游戏 bzoj-1059 ZJOI-2007 题目大意:给定一个n*n的棋盘,上面有一些格子被染黑,剩下都是白色.你每次可以交换两列或者两行,问你能否通过一系列操作使得棋盘的主对角线上的格子全是黑 ...
- 洛谷—— P3386 【模板】二分图匹配
P3386 [模板]二分图匹配(复习) 题目背景 二分图 题目描述 给定一个二分图,结点个数分别为n,m,边数为e,求二分图最大匹配数 输入输出格式 输入格式: 第一行,n,m,e 第二至e+1行,每 ...
- spring-kafka
spring-kafka 使用spring-kafka的小伙伴,看过来. 说明 因为spring-kafka封装的比较厉害,可能跟你实际使用起来有很大的差别. 一个简单的消费例子 在spring-bo ...
- jquery校验框架
http://www.validform.club/ http://craftpip.github.io/jquery-confirm/
- 制作svg动画
要实现一步一步画出来一个图片,css3做不到吧.除非一张张的图片定时显示.想不到别的招了.如今用的是一个插件,做了一个svg动画. 插件地址:http://lazylinepainter.info/ ...
- div拖拽缩放jquery插件编写——带8个控制点
项目中需要对div进行拖拽缩放,需要有控制面板8个控制点的那种,原以为这么常见的效果应该能搜索到很多相关插件,然而可以完成拖拽的实繁,却找不到我想要的,还是自己动手丰衣足食吧 效果预览(只支持pc端) ...
- php高效获取数据分页
mysql.php 获取数据库中的记录,全然个人经验总结,仅供參考! <? php /** *PHP+MYSQL数据库基本功能 *http://blog.csdn.net/yown */ ### ...
- Java集合类汇总记录--JDK篇
接口类图 Java Collection由两套并行的接口组成,一套是Collection接口,一套是Map接口.例如以下图 watermark/2/text/aHR0cDovL2Jsb2cuY3Nkb ...