链接

计算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(组合)的更多相关文章

  1. 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] ...

  2. 『The Counting Problem 数位dp』

    The Counting Problem Description 求 [L,R]内每个数码出现的次数. Input Format 若干行,一行两个正整数 L 和 R. 最后一行 L=R=0,表示输入结 ...

  3. POJ2282 The Counting Problem

    题意 Language:DefaultEspañol The Counting Problem Time Limit: 3000MS Memory Limit: 65536K Total Submis ...

  4. The Counting Problem

    The Counting Problem 询问区间\([a,b]\)中\(1\sim 9\)出现的次数,0 < a, b < 100000000. 解 显然为数位递推,考虑试填法,现在关键 ...

  5. UVa 1640 - The Counting Problem(数论)

    链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...

  6. UVA 1640 The Counting Problem

    https://vjudge.net/problem/UVA-1640 题意:统计区间[l,r]中0——9的出现次数 数位DP 注意删除前导0 #include<cmath> #inclu ...

  7. [POJ 2282] The Counting Problem

    [题目链接] http://poj.org/problem?id=2282 [算法] 数位DP [代码] #include <algorithm> #include <bitset& ...

  8. POJ2282:The Counting Problem(数位DP)

    Description Given two integers a and b, we write the numbers between a and b, inclusive, in a list. ...

  9. UVa 1640 (计数) The Counting Problem

    题意: 统计[a, b]或[b, a]中0~9这些数字各出现多少次. 分析: 这道题可以和UVa 11361比较来看. 同样是利用这样一个“模板”,进行区间的分块,加速运算. 因为这里没有前导0,所以 ...

随机推荐

  1. setTimeout 传递的方法

    function waitExe(param){ if(time < 20){ time ++; $("#content").html(time); var self=thi ...

  2. leetcode 681. Next Closest Time

    Given a time represented in the format "HH:MM", form the next closest time by reusing the ...

  3. js中数组遍历的几种方法及其区别

    参考网站: http://www.cnblogs.com/lvmh/p/6104397.html 第一种最常用的:for循环 for(j = 0; j < arr.length; j++) { ...

  4. POJ2976 Dropping tests —— 01分数规划 二分法

    题目链接:http://poj.org/problem?id=2976 Dropping tests Time Limit: 1000MS   Memory Limit: 65536K Total S ...

  5. codeforces 447C. DZY Loves Sequences 解题报告(446A)

    题目链接:http://codeforces.com/problemset/problem/447/C 题目意思:给出 一个 包含 n 个数的序列你,从中需要找出这个序列的最长子串,满足在里面只修改其 ...

  6. Oracle: 禁忌给一般用户授权create any procedure、execute any procedure

    给一般用户授 create any procedure.execture any procedure 这2个权限是很不安全的事. 因为授权后,通过一些处理,该用户可以取得dba权限,请一定注意. 下面 ...

  7. C++数组作为函数参数的几个问题(转)

    本文需要解决C++中关于数组的2个问题:1. 数组作为函数参数,传值还是传址?2. 函数参数中的数组元素个数能否确定? 先看下面的代码. #include <iostream> using ...

  8. I.MX6 eMMC分区挂载

    /********************************************************************* * I.MX6 eMMC分区挂载 * 说明: * 如果想要 ...

  9. 使用SVPullToRefresh实现下拉刷新和下拉加载

    移动端开发中,“下拉刷新”和“上拉加载更多”早已在各大App中随处可见.也非常容易就能找到直接可供使用的第三方资源.譬如EGOTableViewPullRefresh(下拉刷新)和LoadMoreTa ...

  10. curl测试dns解析时间及tcp连接时间

    1.用Linux下的curl命令测量网络请求(分号是分隔符,可以是其他符号): curl -o /dev/null -s -w %{time_connect}:%{time_starttransfer ...