poj 3405 How many 0's?
来源:互联网 发布:php class中使用use 编辑:程序博客网 时间:2024/05/22 03:08
题目要求统计从m到n 的数字当中,0出现了几次。比如 99-101: 99 100 101 这里0 出现了3次
#include <cstdio> #include <iostream>#include <string.h> #include <cmath>#include <vector>#include <algorithm> using namespace std;typedef long long ll;#define sfint(x) scanf("%d",&x)#define sfint2(x,y) scanf("%d%d",&x,&y)#define sfint3(x,y,z) scanf("%d%d%d",&x,&y,&z)#define sfstr(c) scanf("%s",c)#define sfdl(x) scanf("%lf",&x)#define sfch(c) scanf("%d",&c)#define pfint(x) printf("%d\n",x)#define fr(i,s,n) for(int i=s;i<n;++i)#define _fr(i,n,s) for(int i=n-1;i>=s;--i)#define cl(a) memset(a,0,sizeof(a))void count_digit(ll x,ll times,ll ans[]){if (x<=0) return ;ll a = x/10,b = x%10;fr(i , 0 ,10) ans[i] += a*times;fr(i , 1, b+1) ans[i] += times;count_digit(a-1,times*10,ans);while(a) ans[a%10] += (b+1)*times,a/=10;}ll ansa[10],ansb[10];ll a,b;int main(){while(1){scanf("%lld%lld",&a,&b);cl(ansa);cl(ansb);if (a== -1 && b == -1) break;if (a>0) a--;else ansb[0]++;count_digit(a,1,ansa);count_digit(b,1,ansb);printf("%lld\n",ansb[0]-ansa[0]);}return 0;}
- poj 3405 How many 0's?
- poj 3286 How many 0's?
- POJ 3286How many 0's?
- poj 3286 How many 0's?
- poj 3286 How many 0's?
- poj-3286-How many 0's?
- POJ 3286 How many 0's?
- POJ 3286 How many 0's?
- poj-3286 How many 0's?
- poj 3286 How Many 0's?
- POJ 3286 How many 0’s?
- How many 0's?
- poj 3286 How many 0's? (数位DP+ 统计)
- poj 3286 How many 0's? --- 数位dp
- How many 0's? - POJ 3286 数位dp
- poj 3286 How many 0's? 按位统计
- POJ 3286 How many 0's?(数论)
- POJ 3286 How many 0's?(数位DP)
- django-贴吧 7.0
- zend studio 9 字体,颜色相关设置
- 用div实现的拖拽效果(适合作首页)
- 如何在Chrome当中下载观看的视频?
- Spring中的FactoryBean
- poj 3405 How many 0's?
- div弹出框拖拽
- 鸡先还是蛋先,当然有答案
- Haxe 2 -> Haxe 3迁移指南
- BMP转成C语言数组文件工具(用image2lcd代替bmp2h.exe)
- 一起来学POSIX thread 之 线程利弊与选择
- vc获取本地IP
- ubuntu下无线网卡解决经历
- 在switch-case中定义变量时当心被“穿越”