又是一道水(zuo si)题~~~
来源:互联网 发布:网络用语凸是什么意思 编辑:程序博客网 时间:2024/04/28 04:18
Description
We'll define S(n) for positive integer n as follows: the number of the n's digits in the decimal base. For example, S(893) = 3,S(114514) = 6.
You want to make a consecutive integer sequence starting from number m (m, m + 1, ...). But you need to pay S(n)·k to add the numbern to the sequence.
You can spend a cost up to w, and you want to make the sequence as long as possible. Write a program that tells sequence's maximum length.
Input
The first line contains three integers w (1 ≤ w ≤ 1016), m (1 ≤ m ≤ 1016), k (1 ≤ k ≤ 109).
Please, do not write the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64dspecifier.
Output
The first line should contain a single integer — the answer to the problem.
Sample Input
9 1 1
9
77 7 7
7
114 5 14
6
1 1 2
0
代码如下:
#include <cstdio>#include <iostream>#include <cmath>typedef unsigned long long ll;using namespace std;int main(){ int i = 0; ll n = 1 , ans = 0, p = 0; ll w, m, k; cin >> w >> m >> k; while(n <= m){ n *= 10; i++; } p += i*(n-m)*k; while(p < w){ ans += n-m; m = n; n *= 10; i++; p += i*(n-m)*k; } p -= i*(n-m)*k; ans += (w-p)/(i*k); cout << ans;}//就为了unsigned long long 折腾了半天我容易吗我
- 又是一道水(zuo si)题~~~
- HDU 3790 又是一道最短路水题
- 又是一道题 Digit Counting
- 又是一道贪心题 活动选择
- 又是一道循环!
- POJ1185 状态压缩DP 又是一道有意义的水题
- POJ 2028 When Can We Meet? (又是一道水题)
- COGS 526 又是一道模板题——左偏树
- 又是一道关于字符串的DP题
- HDOJ1258 又是一道深搜入门题
- 又一道简单题
- 又一道简单题
- 又一道简单题 CSU
- zoj 1716 又是一道简单题。直接暴力枚举实现!
- play on words又是一道改了很久的题
- 又是一道快慢指针与链表的结合题 Linked List Cycle II
- HDU 1159 Common Subsequence DP 又一道水题
- 这是一道水题 UESTC
- Ueditor实现自定义conttoller请求或跨域请求
- 【leetcode】122.Best Time to Buy and Sell Stock II
- hdu 3746 (kmp)
- gtk/gtk.h 没有那个文件或目录 的解决方法
- 激光二维扫描传感器
- 又是一道水(zuo si)题~~~
- Linux内存池技术
- Android测试游戏帧数的方法
- 启动Tomcat报错——Eclipse Removing obsolete files from server
- sql学习笔记整理
- 一个Maven实现的邮件模块
- 动态规划DP
- 我的书单
- 手机还能用多久