HDOJ 4734 F(x)】的更多相关文章

数位DP.... F(x) Time Limit: 1000/500 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 750    Accepted Submission(s): 286 Problem Description For a decimal number x with n digits (AnAn-1An-2 ... A2A1), we define its weig…
原题直通车:HDU 4734 F(x) 题意:F(x) = An * 2n-1 + An-1 * 2n-2 + ... + A2 * 2 + A1 * 1, 求0.....B中F[x]<=F[A]的个数. 代码: // 31MS 548K 931 B G++ #include<iostream> #include<cstdio> #include<cstring> using namespace std; int digit[11], dp[11][6000],…
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=4734 数位DP. 用dp[i][j][k] 表示第i位用j时f(x)=k的时候的个数,然后需要预处理下小于k的和,然后就很容易想了 dp[i+1][j][k+(1<<i)]=dp[i][j1][k];(0<=j1<=j1) AC代码: #include <iostream> #include <cstdio> #include <cstring> #i…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4734 Time Limit: 1000/500 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Problem Description For a decimal number x with n digits (AnAn-1An-2 ... A2A1), we define its weight as F(x) = An * 2n…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4734 题意:我们定义十进制数x的权值为f(x) = a(n)*2^(n-1)+a(n-1)*2(n-2)+...a(2)*2+a(1)*1,a(i)表示十进制数x中第i位的数字. 题目给出a,b,求出0~b有多少个不大于f(a)的数 显然这题可以设这样的dp dp[len][count]表示前len位权值为count的有多少,然后显然的在len==0时return count>=f(a); 但是这样…
这题可能非递归版好写? #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; ][],ret=,bit[]; void get_table() { ;i<=;i++) dp[][i]=; ;i<=;i++) dp[][i]=; ;i<=;i++) ;j<=;j++) ;k<=;k++) <…
F(N) Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4078    Accepted Submission(s): 1432 Problem Description Giving the N, can you tell me the answer of F(N)?   Input Each test case contains a…
Problem Description Giving the N, can you tell me the answer of F(N)? Input Each test case contains a single integer N(1<=N<=10^9). The input is terminated by a set starting with N = 0. This set should not be processed. Output For each test case, ou…
For a decimal number x with n digits (A nA n-1A n-2 ... A 2A 1), we define its weight as F(x) = A n * 2 n-1 + A n-1 * 2 n-2 + ... + A 2 * 2 + A 1 * 1. Now you are given two numbers A and B, please calculate how many numbers are there between 0 and B,…
这道题还是关于数位DP的板子题 数位DP有一个显著的特征,就是求的东西大概率与输入关系不大,理论上一般都是数的构成规律 然后这题就是算一个\( F(A) \)的公式值,然后求\( \left [ 0 ,  B \right ] \)区间内\( F(x) \)不大于\( F(A) \)的数的个数 所以由数据范围很容易得到计算出最大值不会超过4600 然后我们设状态\( dp[10][4600][4600] \)表示不同\( F(A) \)取值下的第\( pos \)个位置的值总和为 \( sumx…