题意:求0~f(b)中,有几个小于等于 f(a)的. 解题关键:数位dp #include<bits/stdc++.h> using namespace std; typedef long long ll; ; ][maxn],a[]; int get(int x){ ; while(x){ a[pos++]=x%; x/=; } return pos; } int f(int x){ ) ; )*+x%; } int dfs(int pos,int sta,bool limit){ ) ;…
题目传送门 F(x) Time Limit: 1000/500 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 8901    Accepted Submission(s): 3503 Problem Description For a decimal number x with n digits (AnAn-1An-2 ... A2A1), we define its weigh…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4734 注意到F(x)的值比较小,所以可以先预处理所有F(x)的组合个数.f[i][j]表示 i 位数时F(x)为 j 的个数,方程容易转移:f[i][1<<i+j]=sigma( f[i][j] ).然后求一下f[i][j]的前缀和,就可以直接统计了.. //STATUS:C++_AC_31MS_684KB #include <functional> #include <algo…
(https://www.pixiv.net/member_illust.php?mode=medium&illust_id=65608478) Problem Description For a decimal number x with n digits (AnAn-1An-2 ... A2A1), we define its weight as F(x) = An * 2n-1 + An-1 * 2n-2 + ... + A2 * 2 + A1 * 1. Now you are given…
题目描述 对于一个非负整数 $x=​​\overline{a_na_{n-1}...a_2a_1}$ ,设 $F(x)=a_n·2^{n-1}+a_{n-1}·2^{n-2}+...+a_2·2^1+a_1·2^0=\sum\limits_{i=1}^na_i·2^{i-1}$ 多次询问 $[0,B]$ 区间内 $F$ 值小于等于 $F(A)$ 的数的个数. 输入 The first line has a number T (T <= 10000) , indicating the number…
思路: 每次枚举数字和也就是取模的f(x),这样方便计算. 其他就是基本的数位Dp了. 代码如下: #include<iostream> #include<stdio.h> #include<algorithm> #include<iomanip> #include<cmath> #include<cstring> #include<vector> #define ll __int64 #define pi acos(-1…
题意 一个整数 (AnAn-1An-2 ... A2A1), 定义 F(x) = An * 2n-1 + An-1 * 2n-2 + ... + A2 * 2 + A1 * 1,求[0..B]内有多少数使得F(x) <= F(A).多组数据,T <= 10000 思路 成都网赛--都是泪T_T-- 很裸的数位DP--一开始我的dp状态是dp[pos][fx],fx表示当前枚举到fx为多少,判断fx<=fa.但这样设计状态的一个问题是对于不同的A,dp[][]表示的状态不同,所以每个T都有…
Problem Description For a decimal number x with n digits (AnAn-1An-2 ... A2A1), we define its weight as F(x) = An * 2n-1 + An-1 * 2n-2 + ... + A2 * 2 + A1 * 1. Now you are given two numbers A and B, please calculate how many numbers are there between…
Problem Description Here is a function f(x): int f ( int x ) { if ( x == 0 ) return 0; return f ( x / 10 ) + x % 10; } Now, you want to know, in a given interval [A, B] (1 <= A <= B <= 10 9), how many integer x that mod f(x) equal to 0.   Input T…
题目链接: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…