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.实现 ...
随机推荐
- HDU 5019 Revenge of GCD
题解:筛出约数,然后计算即可. #include <cstdio> #include <algorithm> typedef long long LL; LL a1[10000 ...
- hdu4491 Windmill Animation (几何)
Windmill Animation Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Other ...
- Yet Another Multiple Problem(bfs好题)
Yet Another Multiple Problem Time Limit : 40000/20000ms (Java/Other) Memory Limit : 65536/65536K ( ...
- j详细说明ava于clone办法
原文地址:http://leihuang.org/2014/11/14/java-clone/ In java, it essentially means the ability to create ...
- BEGIN_SINK_MAP(CMainDlg) SINK_ENTRY(IDC_EXPLORER1, ..。响应不到的
</pre><pre name="code" class="cpp"> class CMainDlg : public CAxDialo ...
- Problem B: Excuses, Excuses!
Description Judge Ito is having a problem with people subpoenaed for jury duty giving rather lame ex ...
- BZOJ 2442: [Usaco2011 Open]修剪草坪( dp )
dp dp[ i ] 表示第 i 个不选 , 前 i 个的选择合法的最小损失 , dp[ i ] = min( dp[ j ] ) ( max( 0 , i - 1 - k ) <= j < ...
- BZOJ 1927: [Sdoi2010]星际竞速(最小费用最大流)
拆点,费用流... ----------------------------------------------------------------------------- #include< ...
- OA项目总结
一.自定义拦截器: 继承AbstractInterceptor,覆写intercept方法,实现功能逻辑,最后在Struts.xml文件中配置了自定义拦截器,首先自定义拦截器栈, <!- ...
- jquery的extend()函数
extend()是在写插件的过程中常用的方法,该方法有一些重载原型. 1.该方法的原型是: extend(dest,src1,src2,src3...); 它的含义是将src1,src2,src3.. ...