hdu 5179 beautiful number】的更多相关文章

beautiful number 问题描述 令 A = \sum_{i=1}^{n}a_i * {10}^{n-i}(1\leq a_i \leq 9)A=∑​i=1​n​​a​i​​∗10​n−i​​(1≤a​i​​≤9)(nn为AA的位数).若AA为“漂亮的数”当且仅当对于任意1 \leq i < n1≤i<n满足a[i] \geq a[i+1]a[i]≥a[i+1]且对于任意1 \leq i \leq n,i < j \leq n1≤i≤n,i<j≤n,满足a[i]a[i]…
beautiful number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 801    Accepted Submission(s): 518 Problem Description Let A=∑ni=1ai∗10n−i(1≤ai≤9)(n is the number of A's digits). We call A as “…
题目链接: hdu: http://acm.hdu.edu.cn/showproblem.php?pid=5179 bc(中文): http://bestcoder.hdu.edu.cn/contests/contest_chineseproblem.php?cid=569&pid=1002 题解: 1.数位dp dp[i][j]表示第i位的数值为j的时候所有合法的情况,转移方程为dp[i][j]+=dp[i-1][k](j%k==0)数位最多为10位,可以离线处理出来. 计算1到x(x十进制按…
原题链接 题意:求[l,r]中高位%低位等于0的数字个数.(不含0)分析:此题有三种方法.1.暴搜,毕竟最多才10个位.2.数位dp,预处理好整体的,再处理细节. dp[i][j]表示第i位上的数字位j的情况数,dp[i][j]+=dp[i-1][k](j%k==0) 3.猜想这样的数字并不多,于是打表. 数位dp #include <cstdio> #include <iostream> #include <cmath> #include <algorithm&…
题意: 一个如果称作是漂亮数,当且仅当满足: 每一位上的数字是[1,9],从高到时低数字大小降序,且有di%dj=0(i<j) 例:931 给一个区间[L,R],问这个区间里有多少个漂亮数. 1≤L≤R≤109 思路: 漂亮数一看就很少.可以直接构造. 哎,,,用了DP+构造,写了好久...其实很简单的一个DFS构造就行了. 过些天补上代码.先贴冗长代码~ 代码: int T,L,R; int wei; int ans1,ans2,ans; int d[15], w[15]; int dp[15…
DFS. /* 5179 */ #include <iostream> #include <algorithm> #include <map> #include <cstdio> #include <cstring> using namespace std; #define MAXN 1500 map<int, bool> tb; int a[MAXN], n, v; ][] = { {,}, {,,,}, {,,,,}, {,,,}…
传送门:hdu 5898 odd-even number 思路:数位DP,套着数位DP的模板搞一发就可以了不过要注意前导0的处理,dp[pos][pre][status][ze] pos:当前处理的位 pre:上一位的奇偶性 status:截止到上一位的连续段的奇偶性 ze:是否有前导0 /************************************************************** Problem:hdu 5898 odd-even number User: yo…
划分树 /* HDU 2665 Kth number 划分树 */ #include<stdio.h> #include<iostream> #include<string.h> #include<algorithm> using namespace std; ; ][MAXN];//表示每层每个位置的值 int sorted[MAXN];//已经排序的数 ][MAXN];//toleft[p][i]表示第i层从1到i有多少个数分入左边 void build…
Codeforces 55D Beautiful Number a positive integer number is beautiful if and only if it is divisible by each of its nonzero digits. Input The first line of the input contains the number of cases t (1 ≤ t ≤ 10). Each of the next t lines contains two…
Cube number on a tree Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 1628    Accepted Submission(s): 382 Problem Description The country Tom living in is famous for traveling. Every year, man…