poj 3286 统计0的个数
#include <iostream> using namespace std;
long long p;
long long a[];
long long solve(long long n){
long long left,m,sum =;
for(int i=;i<;i++){
left = n/a[i]-;
sum += left*a[i-];
m = (n%a[i]-n%a[i-])/a[i-];
if(m>) sum += a[i-];
else if(m==) sum += n%a[i-]+;
if(n<a[i]) break;
}
return sum;
} int main()
{
a[] =;
for(int i=;i<;i++)
a[i] =a[i-]*;
long long m,n;
while(cin>>m>>n){
if(m<)
break;
if(n==){
cout<<<<endl;
continue;
}
long long res1 = solve(n);
long long res2 = solve(m-);
//cout<<p<<endl;
//cout<<res1<<" "<<res2<<endl;
cout<<res1-res2<<endl;
}
return ;
}
/**
if(n<0)
return 0;
long long low;
long long high;
long long cur;
p =1;
int tmp=0;
long long cnt =0;
while(n/p!=0){
tmp ++;
low = n-(n/p)*p;
high = n/(p*10)-1;
cur = (n/p)%10;
switch (cur){
case 0:
cnt += high*p+low+1;
break;
default:
cnt += (high+1)*p;
break;
}
p =p*10;
}
//for(int i=0;i<tmp;i++){
// cnt -= a[i];
//}
return cnt;
*/
poj 3286 统计0的个数的更多相关文章
- POJ 3286 How many 0's?(几多0?)
POJ 3286 How many 0's?(几多0?) Time Limit: 1000MS Memory Limit: 65536K [Description] [题目描述] A Benedi ...
- POJ 3286 How many 0's(数位DP模板)
题目链接:http://poj.org/problem?id=3286 题目大意: 输入n,m,求[n,m]的所有数字中,0出现的总数是多少,前导零不算. 解题思路: 模板题,设dp[pos][num ...
- POJ 3286 How many 0's?(数位DP)
题目链接 终于过了,边界让我wa了好几次,猥琐的用AC代码对拍,很无奈,用非常麻烦的方法.写一下,估计以后再碰到,肯定看不懂这是写的什么了. 以前做过,统计1和2的,统计0比1和2麻烦多了,有前导0的 ...
- POJ 3286 How many 0's?
题目链接 题意 :写下m到n之间所有的数,会写多少个0. 思路 :先算0到m的,再算0到n的,最后相减. 网上有位大神是这么推的,看下面.... 首先转化成求 [0, x] 中所有数中,含有的 0 的 ...
- Poj 1401 Factorial(计算N!尾数0的个数——质因数分解)
一.Description The most important part of a GSM network is so called Base Transceiver Station (BTS). ...
- POJ 1236--Network of Schools【scc缩点构图 && 求scc入度为0的个数 && 求最少加几条边使图变成强联通】
Network of Schools Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 13325 Accepted: 53 ...
- POJ 1401:Factorial 求一个数阶乘的末尾0的个数
Factorial Time Limit: 1500MS Memory Limit: 65536K Total Submissions: 15137 Accepted: 9349 Descri ...
- Java 计算N阶乘末尾0的个数-LeetCode 172 Factorial Trailing Zeroes
题目 Given an integer n, return the number of trailing zeroes in n!. Note: Your solution should be in ...
- 原创:C语言打开、下载、删除网页,统计网页字符个数
本程序由本人在华夏联盟的ID闪电笨笨原创,首发地址:http://bbs.hx95.com/ 写此程序希望可以可以激发新手学习C语言的积极性! C语言代码实现功能如下: 1.实现 ...
随机推荐
- When Is Cheryl's Birthday
大早上起来逛微博,看见@西瓜大丸子汤Po的一个逻辑题,遂点开看之... 原文链接:http://nbviewer.ipython.org/url/norvig.com/ipython/Cheryl.i ...
- java 获取随机数的三种方法
方法1(数据类型)(最小值+Math.random()*(最大值-最小值+1))例:(int)(1+Math.random()*(10-1+1))从1到10的int型随数 方法2获得随机数for (i ...
- mybatis-generator生成model和dao层代码
.建立文件夹myibatisGen 2.下载mybatis-generator-core-1.3.1.jar或者其它版本的jar包,到myibatisGen文件夹下 3.为生成代码建立配置文件“gen ...
- Android乐学成语之自定义Adapter
一.首先对Adapter概念深刻的了解 首先看看他的继承图
- 安装cocopods 更新ruby
最近弄cocoapods出现如标题提示 So度娘一番.感谢作者.纯属学习没有商业用途 1.打开终端 终端输入 $ruby -v 查看ruby的版本 打印代码: ruby 2.0.0p648 (2 ...
- Mac搭建Java开发环境
参考博文: http://shupeng.org/2012/10/14/config-java-env-on-mac/ http://hdu104.com/23 注意事项: (Mac OS X - M ...
- eclipse maven SLF4J: Failed to load class org.slf4j.impl.StaticLoggerBinder
现象:运行eclipse maven build,console 有红色日志如下: SLF4J: Failed to load class "org.slf4j.impl.StaticLog ...
- jbpmAPI-7
7.1. Introduction 业务流程的一个重要方面是人工任务管理.虽然一些执行的工作过程中可以自动执行一些任务需要执行的人类演员.jBPM支持特殊的人工任务节点内部流程建模与人类用户交互.这个 ...
- (Problem 46)Goldbach's other conjecture
It was proposed by Christian Goldbach that every odd composite number can be written as the sum of a ...
- Windows10笔记本双显卡导致的启动黑屏解决办法之一
参考链接:http://www.zhihu.com/question/33662311 大概就是关掉ulps. ulps,显卡的多核心超低功率状态,节能用的,AMD出的双显卡的一种节能方案.不过,与某 ...