Making Sequences is Fun(简单枚举)
来源:互联网 发布:查询淘宝页面历史快照 编辑:程序博客网 时间:2024/06/05 19:46
http://codeforces.com/problemset/problem/373/B
题意:S(n)表示一个数字的位数,w表示拥有的金钱,m表示起始数,k表示每一位数字的花费。问从m开始最多可以有多少个数。
注意:理解题意后,把过程简单化。注意 m的上限是10的16次方,m增加的上限超过10的16次方,所以初始化b数组的时候,记得弄大一些。
#include"iostream"#include"cstring"#include"cstdio"#define maxn 50005#define LL __int64using namespace std;LL w,m,k,cnt,ans;LL b[20];int main(){ b[0]=1,b[1]=10; for(int i=2;i<=20;i++) { b[i]=b[i-1]*10; } while(~scanf("%I64d%I64d%I64d",&w,&m,&k)) { w/=k; ans=0; for(int i=0;i<20;i++) if(m<b[i]) { cnt=i; break; } while(w) { if(w>=(b[cnt]-m)*cnt) { ans += b[cnt]-m; w -= (b[cnt]-m)*cnt; m = b[cnt]; } else { ans += w/cnt; w=0; } cnt++; } printf("%I64d\n",ans); } return 0;}
0 0
- Making Sequences is Fun(简单枚举)
- CodeForces 373 B. Making Sequences is Fun
- CodeForces 373B Making Sequences is Fun
- codeforces#219_div2_B Making Sequences is Fun
- CodeForces 373B Making Sequences is Fun
- codeforces#373B.Making Sequences is Fun
- Making AI Fun: When Good Enough is Good Enough
- Codeforces373B_Making Sequences is Fun_枚举长度。。。
- Codeforces 372B. Counting Rectangles is Fun【动态规划,暴力枚举】(lowbit()小用法)
- Making Fun of Things with OCMock
- 【CodeForce 734C 】Anton and Making Potions (枚举+二分)
- Codeforces-734C-Anton and Making Potions(枚举+二分)
- poj 2818 Making Change 枚举
- Programming is fun
- Dog eating is fun
- Machine Learning is Fun!
- Counting Kangaroos is Fun
- 【UVA】11437Triangle Fun(简单几何)
- 掌握设计模式
- android_rpg 天龙群侠传
- (java)Rectangle Area
- Spring框架(二)--AOP面向切面编程
- 第9周项目3-稀疏矩阵的三元组表示的应用(3.2).cpp
- Making Sequences is Fun(简单枚举)
- 【ssh学习笔记】struts处理json异常之JSONWriter can not access a member of class org.springframework.aop.TruePoin
- 如何优化UITableView性能
- 第9周项目4-广义表算法库(4.1).cpp
- python读写Excel
- C#由指定数据生成灰度位图或者彩色位图
- ios8调用相机报警告: Snapshotting a view that has not been rendered results in an empty snapshot. Ensure yo
- Hbase shell 常用命令
- (java)Contains Duplicate II