poj2282The Counting Problem(组合)
计算0-9每一个数字出现的次数 逐位进行处理 对于每一位取几时依次算下组合的情况 注意0的情况需要特殊处理一下 因为0000 00 这样都是等于0的 前面的几位是多余的
#include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<vector>
#include<cmath>
#include<queue>
#include<set>
using namespace std;
#define N 100000
#define LL long long
#define INF 0xfffffff
const double eps = 1e-;
const double pi = acos(-1.0);
const double inf = ~0u>>;
int d[],dd[];
int an[];
void judge(int xx,int x[],int f)
{
if(!xx) return ;
int i,j,e;
int p[],g=;
int y = xx;
while(xx)
{
p[++g] = xx%;
xx/=;
}
int o = ;
x[]+=;
for(i = g ; i >= ; i--)
{
for(i==g?j = :j= ; j < p[i] ; j++)
{
x[j]+=pow(10.0,g-o);
}
for(j = i- ; j>= ; j--)
{
int ko;
if(i==g)
{
if(j==i-)
ko = pow(10.0,g-o-)*(p[i]-);
else
ko = pow(10.0,g-o-)*(p[i]-)+(pow(10.0,(i-j-))-)*pow(10.0,j-);
}
else ko = pow(10.0,g-o-)*p[i];
//cout<<ko<<" "<<i<<" "<<j<<" "<<o<<endl;
x[]+=ko;
for(e = ; e <= ; e++)
{
x[e]+=pow(10.0,g-o-)*p[i];
}
}
int k = pow(10.0,g-o);
x[p[i]] += y%k+;
o++;
} if(f)
{
for(i = ;i <= g ;i++)
x[p[i]]--;
}
}
int main()
{
int i,a,b;
while(cin>>a>>b)
{
if(!a&&!b) break;
if(a>b) swap(a,b);
memset(d,,sizeof(d));
memset(dd,,sizeof(dd));
judge(a,d,);
judge(b,dd,);
for(i = ;i < ;i++)
cout<<dd[i]-d[i]<<" ";
cout<<dd[]-d[]<<endl;
}
return ;
}
poj2282The Counting Problem(组合)的更多相关文章
- UVA 1640 The Counting Problem UVA1640 求[a,b]或者[b,a]区间内0~9在里面各个数的数位上出现的总次数。
/** 题目:UVA 1640 The Counting Problem UVA1640 链接:https://vjudge.net/problem/UVA-1640 题意:求[a,b]或者[b,a] ...
- 『The Counting Problem 数位dp』
The Counting Problem Description 求 [L,R]内每个数码出现的次数. Input Format 若干行,一行两个正整数 L 和 R. 最后一行 L=R=0,表示输入结 ...
- POJ2282 The Counting Problem
题意 Language:DefaultEspañol The Counting Problem Time Limit: 3000MS Memory Limit: 65536K Total Submis ...
- The Counting Problem
The Counting Problem 询问区间\([a,b]\)中\(1\sim 9\)出现的次数,0 < a, b < 100000000. 解 显然为数位递推,考虑试填法,现在关键 ...
- UVa 1640 - The Counting Problem(数论)
链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...
- UVA 1640 The Counting Problem
https://vjudge.net/problem/UVA-1640 题意:统计区间[l,r]中0——9的出现次数 数位DP 注意删除前导0 #include<cmath> #inclu ...
- [POJ 2282] The Counting Problem
[题目链接] http://poj.org/problem?id=2282 [算法] 数位DP [代码] #include <algorithm> #include <bitset& ...
- POJ2282:The Counting Problem(数位DP)
Description Given two integers a and b, we write the numbers between a and b, inclusive, in a list. ...
- UVa 1640 (计数) The Counting Problem
题意: 统计[a, b]或[b, a]中0~9这些数字各出现多少次. 分析: 这道题可以和UVa 11361比较来看. 同样是利用这样一个“模板”,进行区间的分块,加速运算. 因为这里没有前导0,所以 ...
随机推荐
- Oracle数据库案例整理-Oracle系统执行时故障-断电导致数据文件状态变为RECOVER
1.1 现象描写叙述异常断电.数据库数据文件的状态由ONLINE变为RECOVER. 系统显演示样例如以下信息:SQL>selectfile_name,tablespace_name, ...
- 字典树(Trie树) C++实现
说明: 以下代码是个人按照自己的理解写的,可能有错误或者不太规范的地方,欢迎指出! 代码如下: //插入.删除.查询.遍历四种操作 //注意:四种操作的函数实现中,T都是指向上一个结点的指针,以此方便 ...
- ES6 对象的解构赋值
对象的解构赋值 解构不仅可以用于数组,还可以用于对象. let {foo,bar} = {foo:"aaa",bar:"bbb"}; console.log(f ...
- [原创]java获取word文档的条目化内容
在开发Web办公系统或文档系统时,PageOffice组件是众所周知的在线处理微软word/ppt/excel文档的强大工具,它对WORD文档的各种处理在API层面进行了封装,屏蔽了Office VB ...
- uuid.js
// On creation of a UUID object, set it's initial valuefunction UUID(){ this.id = this.createUUID ...
- Linux网络编程笔记(修订版)
我的网络编程笔记, 因为最近又要做Linux下的网络编程,故重新修订, 其中一些内容参考了文末的链接及文章 1. 基本概念 2. 基本接口 2.1. 打开一个socket 2.2. 将 ...
- 单片机知识是Linux驱动开发的基础之一
这是arm裸机1期加强版第1课第2节课程的wiki文字版. 为什么没前途也要学习单片机? 因为它是个很好的入口. 学习单片机可以让我们抛开复杂的软件结构,先掌握硬件操作,如:看原理图.芯片手册.写程序 ...
- 文件的创建,读取,写入,修改,删除---python入门
转自:http://blog.163.com/jackylau_v/blog/static/175754040201181505158356/ 一.用Python创建一个新文件,内容是从0到9的整数, ...
- linux C之access函数(转载)
转自:http://blog.sina.com.cn/s/blog_6a1837e90100uh5d.html access():判断是否具有存取文件的权限 相关函数 stat,open,chm ...
- 实现node端渲染图表的简单方案
实现node端渲染图表的简单方案 这个题目有点小,本篇博客真正谈论的应该是服务端生成图表的简单方案,这里面有两个关键字:服务端 & 简单,我们知道基于js有很多的图表库,知名的如D3.echa ...